7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
23 # 63 min 7 min AT AT AT AT"
24 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 6b 12 16 44 44b 65 66 67 68"
28 cleanup_and_setup_lustre
32 rm -rf $DIR/[df][0-9]*
38 run_test 0 "empty replay"
41 # this test attempts to trigger a race in the precreation code,
42 # and must run before any other objects are created on the filesystem
44 createmany -o $DIR/$tfile 20 || return 1
45 unlinkmany $DIR/$tfile 20 || return 2
47 run_test 0b "ensure object created after recover exists. (3284)"
53 $CHECKSTAT -t file $DIR/$tfile || return 1
56 run_test 1 "simple create"
59 do_facet ost1 "sysctl -w lustre.fail_loc=0"
62 local old_last_id=`cat $LPROC/obdfilter/*/last_id`
63 touch -o $DIR/$tfile 1
65 local new_last_id=`cat $LPROC/obdfilter/*/last_id`
67 test "$old_last_id" = "$new_last_id" || {
68 echo "OST object create is caused by MDS"
72 old_last_id=`cat $LPROC/obdfilter/*/last_id`
73 echo "data" > $DIR/$tfile
75 new_last_id=`cat $LPROC/obdfilter/*/last_id`
76 test "$old_last_id" = "$new_last_id "&& {
77 echo "CROW does not work on write"
83 #define OBD_FAIL_OST_CROW_EIO | OBD_FAIL_ONCE
84 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000801"
87 old_last_id=`cat $LPROC/obdfilter/*/last_id`
88 echo "data" > $DIR/1a1
90 new_last_id=`cat $LPROC/obdfilter/*/last_id`
91 test "$old_last_id" = "$new_last_id" || {
92 echo "CROW does work with fail_loc=0x80000801"
98 do_facet ost1 "sysctl -w lustre.fail_loc=0"
100 #CROW run_test 1a "CROW object create (check OST last_id)"
106 $CHECKSTAT -t file $DIR/$tfile || return 1
116 $CHECKSTAT -t file $DIR/$tfile || return 1
124 o_directory $DIR/$tfile
126 $CHECKSTAT -t file $DIR/$tfile || return 2
129 run_test 3a "replay failed open(O_DIRECTORY)"
133 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
134 do_facet mds "sysctl -w lustre.fail_loc=0x80000114"
136 do_facet mds "sysctl -w lustre.fail_loc=0"
138 $CHECKSTAT -t file $DIR/$tfile && return 2
141 run_test 3b "replay failed open -ENOMEM"
145 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
146 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
148 do_facet mds "sysctl -w lustre.fail_loc=0"
151 $CHECKSTAT -t file $DIR/$tfile && return 2
154 run_test 3c "replay failed open -ENOMEM"
158 for i in `seq 10`; do
159 echo "tag-$i" > $DIR/$tfile-$i
162 for i in `seq 10`; do
163 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
166 run_test 4 "|x| 10 open(O_CREAT)s"
172 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
174 run_test 4b "|x| rm 10 files"
176 # The idea is to get past the first block of precreated files on both
177 # osts, and then replay.
180 for i in `seq 220`; do
181 echo "tag-$i" > $DIR/$tfile-$i
184 for i in `seq 220`; do
185 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
189 # waiting for commitment of removal
191 run_test 5 "|x| 220 open(O_CREAT)"
196 mcreate $DIR/$tdir/$tfile
198 $CHECKSTAT -t dir $DIR/$tdir || return 1
199 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
201 # waiting for log process thread
203 run_test 6 "mkdir + contained create"
209 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
211 run_test 6b "|X| rmdir"
215 mcreate $DIR/$tdir/$tfile
217 $CHECKSTAT -t dir $DIR/$tdir || return 1
218 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
221 run_test 7 "mkdir |X| contained create"
225 multiop_bg_pause $DIR/$tfile mo_c || return 4
229 $CHECKSTAT -t file $DIR/$tfile || return 1
230 kill -USR1 $MULTIPID || return 2
231 wait $MULTIPID || return 3
234 run_test 8 "creat open |X| close"
239 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
241 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
243 echo " old_inum == $old_inum, new_inum == $new_inum"
244 if [ $old_inum -eq $new_inum ] ;
246 echo " old_inum and new_inum match"
248 echo "!!!! old_inum and new_inum NOT match"
253 run_test 9 "|X| create (same inum/gen)"
258 mv $DIR/$tfile $DIR/$tfile-2
261 $CHECKSTAT $DIR/$tfile && return 1
262 $CHECKSTAT $DIR/$tfile-2 ||return 2
266 run_test 10 "create |X| rename unlink"
270 echo "old" > $DIR/$tfile
271 mv $DIR/$tfile $DIR/$tfile-2
273 echo "new" > $DIR/$tfile
275 grep old $DIR/$tfile-2
277 grep new $DIR/$tfile || return 1
278 grep old $DIR/$tfile-2 || return 2
280 run_test 11 "create open write rename |X| create-old-name read"
284 multiop_bg_pause $DIR/$tfile o_tSc || return 3
289 wait $pid || return 1
292 [ -e $DIR/$tfile ] && return 2
295 run_test 12 "open, unlink |X| close"
298 # 1777 - replay open after committed chmod that would make
299 # a regular open a failure
302 multiop_bg_pause $DIR/$tfile O_wc || return 3
305 $CHECKSTAT -p 0 $DIR/$tfile
309 wait $pid || return 1
311 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
314 run_test 13 "open chmod 0 |x| write close"
317 multiop_bg_pause $DIR/$tfile O_tSc || return 4
321 kill -USR1 $pid || return 1
322 wait $pid || return 2
325 [ -e $DIR/$tfile ] && return 3
328 run_test 14 "open(O_CREAT), unlink |X| close"
331 multiop_bg_pause $DIR/$tfile O_tSc || return 5
335 touch $DIR/g11 || return 1
337 wait $pid || return 2
340 [ -e $DIR/$tfile ] && return 3
341 touch $DIR/h11 || return 4
344 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
351 mcreate $DIR/$tfile-2
353 [ -e $DIR/$tfile ] && return 1
354 [ -e $DIR/$tfile-2 ] || return 2
355 munlink $DIR/$tfile-2 || return 3
357 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
361 multiop_bg_pause $DIR/$tfile O_c || return 4
364 kill -USR1 $pid || return 1
365 wait $pid || return 2
366 $CHECKSTAT -t file $DIR/$tfile || return 3
369 run_test 17 "|X| open(O_CREAT), |replay| close"
373 multiop_bg_pause $DIR/$tfile O_tSc || return 8
376 touch $DIR/$tfile-2 || return 1
377 echo "pid: $pid will close"
379 wait $pid || return 2
382 [ -e $DIR/$tfile ] && return 3
383 [ -e $DIR/$tfile-2 ] || return 4
384 # this touch frequently fails
385 touch $DIR/$tfile-3 || return 5
386 munlink $DIR/$tfile-2 || return 6
387 munlink $DIR/$tfile-3 || return 7
390 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
392 # bug 1855 (a simpler form of test_11 above)
396 echo "old" > $DIR/$tfile
397 mv $DIR/$tfile $DIR/$tfile-2
398 grep old $DIR/$tfile-2
400 grep old $DIR/$tfile-2 || return 2
402 run_test 19 "|X| mcreate, open, write, rename "
406 multiop_bg_pause $DIR/$tfile O_tSc || return 3
412 wait $pid || return 1
413 [ -e $DIR/$tfile ] && return 2
416 run_test 20 "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
418 test_20b() { # bug 10480
419 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
421 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
423 while [ ! -e $DIR/$tfile ] ; do
424 sleep 0.060s # give dd a chance to start
427 lfs getstripe $DIR/$tfile || return 1
428 rm -f $DIR/$tfile || return 2 # make it an orphan
430 df -P $DIR || df -P $DIR || true # reconnect
432 fail mds # start orphan recovery
433 df -P $DIR || df -P $DIR || true # reconnect
434 wait_mds_recovery_done || error "MDS recovery not done"
436 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
437 log "before $BEFOREUSED, after $AFTERUSED"
438 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
439 error "after $AFTERUSED > before $BEFOREUSED" && return 5
442 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
444 test_20c() { # bug 10480
445 multiop $DIR/$tfile Ow_c &
447 # give multiop a chance to open
454 df -P $DIR || df -P $DIR || true # reconnect
457 test -s $DIR/$tfile || error "File was truncated"
461 run_test 20c "check that client eviction does not affect file content"
465 multiop_bg_pause $DIR/$tfile O_tSc || return 5
468 touch $DIR/g11 || return 1
472 wait $pid || return 2
473 [ -e $DIR/$tfile ] && return 3
474 touch $DIR/h11 || return 4
477 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
480 multiop_bg_pause $DIR/$tfile O_tSc || return 3
488 wait $pid || return 1
489 [ -e $DIR/$tfile ] && return 2
492 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
495 multiop_bg_pause $DIR/$tfile O_tSc || return 5
500 touch $DIR/g11 || return 1
504 wait $pid || return 2
505 [ -e $DIR/$tfile ] && return 3
506 touch $DIR/h11 || return 4
509 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
512 multiop_bg_pause $DIR/$tfile O_tSc || return 3
519 wait $pid || return 1
520 [ -e $DIR/$tfile ] && return 2
523 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
526 multiop_bg_pause $DIR/$tfile O_tSc || return 3
533 wait $pid || return 1
534 [ -e $DIR/$tfile ] && return 2
537 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
541 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
543 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
548 wait $pid2 || return 1
552 wait $pid1 || return 2
553 [ -e $DIR/$tfile-1 ] && return 3
554 [ -e $DIR/$tfile-2 ] && return 4
557 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
561 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
563 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
570 wait $pid1 || return 1
572 wait $pid2 || return 2
573 [ -e $DIR/$tfile-1 ] && return 3
574 [ -e $DIR/$tfile-2 ] && return 4
577 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
580 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
582 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
588 wait $pid2 || return 1
592 wait $pid1 || return 2
593 [ -e $DIR/$tfile-1 ] && return 3
594 [ -e $DIR/$tfile-2 ] && return 4
597 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
600 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
602 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
610 wait $pid1 || return 1
612 wait $pid2 || return 2
613 [ -e $DIR/$tfile-1 ] && return 3
614 [ -e $DIR/$tfile-2 ] && return 4
617 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
620 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
622 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
630 wait $pid1 || return 1
632 wait $pid2 || return 2
633 [ -e $DIR/$tfile-1 ] && return 3
634 [ -e $DIR/$tfile-2 ] && return 4
637 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
640 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
642 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
650 wait $pid1 || return 1
652 wait $pid2 || return 2
653 [ -e $DIR/$tfile-1 ] && return 3
654 [ -e $DIR/$tfile-2 ] && return 4
657 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
659 # tests for bug 2104; completion without crashing is success. The close is
660 # stale, but we always return 0 for close, so the app never sees it.
662 multiop_bg_pause $DIR/$tfile O_c || return 2
664 multiop_bg_pause $DIR/$tfile O_c || return 3
667 df $MOUNT || sleep 1 && df $MOUNT || return 1
673 run_test 32 "close() notices client eviction; close() after client eviction"
675 # Abort recovery before client complete
678 createmany -o $DIR/$tfile-%d 100
680 # this file should be gone, because the replay was aborted
681 $CHECKSTAT -t file $DIR/$tfile-* && return 3
682 unlinkmany $DIR/$tfile-%d 0 100
685 run_test 33 "abort recovery before client does replay"
688 multiop_bg_pause $DIR/$tfile O_c || return 2
695 [ -e $DIR/$tfile ] && return 1
699 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
701 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
705 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
706 do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
711 # give a chance to remove from MDS
713 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
715 run_test 35 "test recovery from llog for unlink op"
717 # b=2432 resent cancel after replay uses wrong cookie,
718 # so don't resend cancels
722 checkstat $DIR/$tfile
725 if dmesg | grep "unknown lock cookie"; then
726 echo "cancel after replay failed"
730 run_test 36 "don't resend cancel"
733 # directory orphans can't be unlinked from PENDING directory
735 rmdir $DIR/$tfile 2>/dev/null
736 multiop_bg_pause $DIR/$tfile dD_c || return 2
741 # clear the dmesg buffer so we only see errors from this recovery
745 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
749 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
752 createmany -o $DIR/$tfile-%d 800
753 unlinkmany $DIR/$tfile-%d 0 400
756 unlinkmany $DIR/$tfile-%d 400 400
758 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
760 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
762 test_39() { # bug 4176
763 createmany -o $DIR/$tfile-%d 800
765 unlinkmany $DIR/$tfile-%d 0 400
767 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 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }' $LPROC/osc/*/stats
780 $LCTL mark multiop $MOUNT/$tfile OS_c
781 multiop $MOUNT/$tfile OS_c &
783 writeme -s $MOUNT/${tfile}-2 &
787 #define OBD_FAIL_MDS_CONNECT_NET 0x117
788 do_facet mds "sysctl -w lustre.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 "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 osc2dev=`grep ${ost2_svc}-osc- $LPROC/devices | awk '{print $1}'`
833 [ "$osc2dev" ] || return 4
834 $LCTL --device $osc2dev deactivate || return 1
835 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
836 $LCTL --device $osc2dev activate || return 2
839 run_test 41 "read from a valid osc while other oscs are invalid"
841 # test MDS recovery after ost failure
843 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
844 createmany -o $DIR/$tfile-%d 800
846 unlinkmany $DIR/$tfile-%d 0 400
848 sysctl -w lnet.debug=-1
851 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
852 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
853 #[ $blocks_after -lt $blocks ] || return 1
854 echo wait for MDS to timeout and recover
855 sleep $((TIMEOUT * 2))
857 unlinkmany $DIR/$tfile-%d 400 400
858 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
860 run_test 42 "recovery after ost failure"
862 # timeout in MDS/OST recovery RPC will LBUG MDS
863 test_43() { # bug 2530
866 # OBD_FAIL_OST_CREATE_NET 0x204
867 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
870 do_facet ost1 "sysctl -w lustre.fail_loc=0"
874 run_test 43 "mds osc import failure during recovery; don't LBUG"
879 mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices`
880 [ "$mdcdev" ] || exit 2
882 # adaptive timeouts slow this way down
883 if at_is_valid && at_is_enabled; then
884 at_max_saved=$(at_max_get mds)
888 for i in `seq 1 10`; do
889 echo "$i of 10 ($(date +%s))"
890 do_facet mds "grep service $LPROC/mdt/MDS/mds/timeouts"
891 #define OBD_FAIL_TGT_CONN_RACE 0x701
892 do_facet mds "sysctl -w lustre.fail_loc=0x80000701"
893 $LCTL --device $mdcdev recover
897 do_facet mds "sysctl -w lustre.fail_loc=0"
898 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
901 run_test 44 "race in target handle connect"
904 mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices`
905 [ "$mdcdev" ] || exit 2
906 for i in `seq 1 10`; do
907 echo "$i of 10 ($(date +%s))"
908 do_facet mds "grep service $LPROC/mdt/MDS/mds/timeouts"
909 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
910 do_facet mds "sysctl -w lustre.fail_loc=0x80000704"
911 $LCTL --device $mdcdev recover
914 do_facet mds "sysctl -w lustre.fail_loc=0"
917 run_test 44b "race in target handle connect"
919 # Handle failed close
921 mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices`
922 [ "$mdcdev" ] || exit 2
923 $LCTL --device $mdcdev recover
925 multiop_bg_pause $DIR/$tfile O_c || return 1
928 # This will cause the CLOSE to fail before even
929 # allocating a reply buffer
930 $LCTL --device $mdcdev deactivate || return 4
934 wait $pid || return 1
936 $LCTL --device $mdcdev activate || return 5
939 $CHECKSTAT -t file $DIR/$tfile || return 2
942 run_test 45 "Handle failed close"
946 drop_reply "touch $DIR/$tfile"
948 # ironically, the previous test, 45, will cause a real forced close,
949 # so just look for one for this test
950 dmesg | grep -i "force closing client file handle for $tfile" && return 1
953 run_test 46 "Don't leak file handle after open resend (3325)"
955 test_47() { # bug 2824
956 # create some files to make sure precreate has been done on all
957 # OSTs. (just in case this test is run independently)
958 createmany -o $DIR/$tfile 20 || return 1
960 # OBD_FAIL_OST_CREATE_NET 0x204
962 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
963 df $MOUNT || return 2
965 # let the MDS discover the OST failure, attempt to recover, fail
967 sleep $((3 * TIMEOUT))
969 # Without 2824, this createmany would hang
970 createmany -o $DIR/$tfile 20 || return 3
971 unlinkmany $DIR/$tfile 20 || return 4
973 do_facet ost1 "sysctl -w lustre.fail_loc=0"
976 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
980 createmany -o $DIR/$tfile 20 || return 1
981 # OBD_FAIL_OST_EROFS 0x216
983 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000216"
984 df $MOUNT || return 2
986 createmany -o $DIR/$tfile 20 20 || return 2
987 unlinkmany $DIR/$tfile 40 || return 3
989 do_facet ost1 "sysctl -w lustre.fail_loc=0"
992 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
995 local oscdev=`do_facet mds grep \'${ost1_svc}-osc \' $LPROC/devices | awk '{print $1}' | head -1`
996 [ "$oscdev" ] || return 1
997 do_facet mds $LCTL --device $oscdev recover || return 2
998 do_facet mds $LCTL --device $oscdev recover || return 3
999 # give the mds_lov_sync threads a chance to run
1002 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1004 # b3764 timed out lock replay
1007 cancel_lru_locks mdc
1009 multiop $DIR/$tfile s || return 1
1011 #define OBD_FAIL_LDLM_REPLY 0x30c
1012 do_facet mds "sysctl -w lustre.fail_loc=0x8000030c"
1013 fail mds || return 2
1014 do_facet mds "sysctl -w lustre.fail_loc=0x0"
1016 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1018 run_test 52 "time out lock replay (3764)"
1020 # bug 3462 - simultaneous MDC requests
1022 mkdir -p $DIR/${tdir}-1
1023 mkdir -p $DIR/${tdir}-2
1024 multiop $DIR/${tdir}-1/f O_c &
1026 # give multiop a chance to open
1029 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1030 do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
1031 kill -USR1 $close_pid
1032 cancel_lru_locks MDC # force the close
1033 do_facet mds "sysctl -w lustre.fail_loc=0"
1034 mcreate $DIR/${tdir}-2/f || return 1
1036 # close should still be here
1037 [ -d /proc/$close_pid ] || return 2
1038 replay_barrier_nodf mds
1040 wait $close_pid || return 3
1042 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1043 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1044 rm -rf $DIR/${tdir}-*
1046 run_test 53a "|X| close request while two MDC requests in flight"
1049 mkdir -p $DIR/$tdir-1
1050 mkdir -p $DIR/$tdir-2
1051 multiop $DIR/$tdir-1/f O_c &
1054 #define OBD_FAIL_MDS_REINT_NET 0x107
1055 do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
1056 mcreate $DIR/${tdir}-2/f &
1060 do_facet mds "sysctl -w lustre.fail_loc=0"
1061 kill -USR1 $close_pid
1062 cancel_lru_locks MDC # force the close
1063 wait $close_pid || return 1
1064 # open should still be here
1065 [ -d /proc/$open_pid ] || return 2
1067 replay_barrier_nodf mds
1069 wait $open_pid || return 3
1071 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1072 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1073 rm -rf $DIR/${tdir}-*
1075 run_test 53b "|X| open request while two MDC requests in flight"
1078 mkdir -p $DIR/${tdir}-1
1079 mkdir -p $DIR/${tdir}-2
1080 multiop $DIR/${tdir}-1/f O_c &
1083 do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
1084 mcreate $DIR/${tdir}-2/f &
1088 do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
1089 kill -USR1 $close_pid
1090 cancel_lru_locks MDC # force the close
1092 replay_barrier_nodf mds
1094 wait $open_pid || return 1
1096 # close should be gone
1097 [ -d /proc/$close_pid ] && return 2
1098 do_facet mds "sysctl -w lustre.fail_loc=0"
1100 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1101 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1102 rm -rf $DIR/${tdir}-*
1104 run_test 53c "|X| open request and close request while two MDC requests in flight"
1107 mkdir -p $DIR/${tdir}-1
1108 mkdir -p $DIR/${tdir}-2
1109 multiop $DIR/${tdir}-1/f O_c &
1111 # give multiop a chance to open
1114 # define OBD_FAIL_MDS_CLOSE_NET_REP 0X138
1115 do_facet mds "sysctl -w lustre.fail_loc=0x8000013b"
1116 kill -USR1 $close_pid
1117 cancel_lru_locks MDC # force the close
1118 do_facet mds "sysctl -w lustre.fail_loc=0"
1119 mcreate $DIR/${tdir}-2/f || return 1
1121 # close should still be here
1122 [ -d /proc/$close_pid ] || return 2
1123 replay_barrier_nodf mds
1125 wait $close_pid || return 3
1127 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1128 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1129 rm -rf $DIR/${tdir}-*
1131 run_test 53d "|X| close reply while two MDC requests in flight"
1134 mkdir -p $DIR/$tdir-1
1135 mkdir -p $DIR/$tdir-2
1136 multiop $DIR/$tdir-1/f O_c &
1139 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1140 do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
1141 mcreate $DIR/${tdir}-2/f &
1145 do_facet mds "sysctl -w lustre.fail_loc=0"
1146 kill -USR1 $close_pid
1147 cancel_lru_locks MDC # force the close
1148 wait $close_pid || return 1
1149 # open should still be here
1150 [ -d /proc/$open_pid ] || return 2
1152 replay_barrier_nodf mds
1154 wait $open_pid || return 3
1156 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1157 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1158 rm -rf $DIR/${tdir}-*
1160 run_test 53e "|X| open reply while two MDC requests in flight"
1163 mkdir -p $DIR/${tdir}-1
1164 mkdir -p $DIR/${tdir}-2
1165 multiop $DIR/${tdir}-1/f O_c &
1168 do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
1169 mcreate $DIR/${tdir}-2/f &
1173 do_facet mds "sysctl -w lustre.fail_loc=0x8000013b"
1174 kill -USR1 $close_pid
1175 cancel_lru_locks MDC
1177 replay_barrier_nodf mds
1179 wait $open_pid || return 1
1181 #close should be gone
1182 [ -d /proc/$close_pid ] && return 2
1183 do_facet mds "sysctl -w lustre.fail_loc=0"
1185 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1186 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1187 rm -rf $DIR/${tdir}-*
1189 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1192 mkdir -p $DIR/${tdir}-1
1193 mkdir -p $DIR/${tdir}-2
1194 multiop $DIR/${tdir}-1/f O_c &
1197 do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
1198 mcreate $DIR/${tdir}-2/f &
1202 do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
1203 kill -USR1 $close_pid
1204 cancel_lru_locks MDC # force the close
1206 do_facet mds "sysctl -w lustre.fail_loc=0"
1207 replay_barrier_nodf mds
1209 wait $open_pid || return 1
1211 # close should be gone
1212 [ -d /proc/$close_pid ] && return 2
1214 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1215 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1216 rm -rf $DIR/${tdir}-*
1218 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1221 mkdir -p $DIR/${tdir}-1
1222 mkdir -p $DIR/${tdir}-2
1223 multiop $DIR/${tdir}-1/f O_c &
1226 do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
1227 mcreate $DIR/${tdir}-2/f &
1231 do_facet mds "sysctl -w lustre.fail_loc=0x8000013b"
1232 kill -USR1 $close_pid
1233 cancel_lru_locks MDC # force the close
1236 replay_barrier_nodf mds
1238 wait $open_pid || return 1
1240 # close should be gone
1241 [ -d /proc/$close_pid ] && return 2
1242 do_facet mds "sysctl -w lustre.fail_loc=0"
1244 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1245 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1246 rm -rf $DIR/${tdir}-*
1248 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1250 #b3761 ASSERTION(hash != 0) failed
1252 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1253 do_facet mds "sysctl -w lustre.fail_loc=0x8000012b"
1255 # give touch a chance to run
1257 do_facet mds "sysctl -w lustre.fail_loc=0x0"
1261 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1263 #b3440 ASSERTION(rec->ur_fid2->id) failed
1265 ln -s foo $DIR/$tfile
1267 #drop_reply "cat $DIR/$tfile"
1271 run_test 56 "don't replay a symlink open request (3440)"
1273 #recovery one mds-ost setattr from llog
1275 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1276 do_facet mds "sysctl -w lustre.fail_loc=0x8000012c"
1281 $CHECKSTAT -t file $DIR/$tfile || return 1
1282 do_facet mds "sysctl -w lustre.fail_loc=0x0"
1285 run_test 57 "test recovery from llog for setattr op"
1287 #recovery many mds-ost setattr from llog
1289 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1290 do_facet mds "sysctl -w lustre.fail_loc=0x8000012c"
1291 createmany -o $DIR/$tdir/$tfile-%d 2500
1295 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1296 do_facet mds "sysctl -w lustre.fail_loc=0x0"
1297 unlinkmany $DIR/$tdir/$tfile-%d 2500
1300 run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)"
1302 # log_commit_thread vs filter_destroy race used to lead to import use after free
1305 createmany -o $DIR/$tdir/$tfile-%d 200
1307 unlinkmany $DIR/$tdir/$tfile-%d 200
1308 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1309 do_facet ost1 "sysctl -w lustre.fail_loc=0x507"
1312 do_facet ost1 "sysctl -w lustre.fail_loc=0x0"
1316 run_test 59 "test log_commit_thread vs filter_destroy race"
1318 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1319 # bug 12086: should no oops and No ctxt error for this test
1321 createmany -o $DIR/$tdir/$tfile-%d 200
1323 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1325 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1326 local no_ctxt=`dmesg | grep "No ctxt"`
1327 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1329 run_test 60 "test llog post recovery init vs llog unlink"
1331 #test race llog recovery thread vs llog cleanup
1333 createmany -o $DIR/$tdir/$tfile-%d 800
1335 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1336 unlinkmany $DIR/$tdir/$tfile-%d 800
1337 do_facet ost "sysctl -w lustre.fail_loc=0x80000221"
1342 do_facet ost "sysctl -w lustre.fail_loc=0x0"
1343 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1346 run_test 61a "test race llog recovery vs llog cleanup"
1348 #test race mds llog sync vs llog cleanup
1350 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1351 do_facet mds "sysctl -w lustre.fail_loc=0x8000013a"
1355 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1357 run_test 61b "test race mds llog sync vs llog cleanup"
1359 #test race cancel cookie cb vs llog cleanup
1361 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1363 do_facet ost "sysctl -w lustre.fail_loc=0x80000222"
1368 run_test 61c "test race mds llog sync vs llog cleanup"
1370 #Adaptive Timeouts (bug 3055)
1375 at_is_valid || skip "AT env is invalid"
1377 if ! at_is_enabled; then
1378 echo "AT is disabled, enable it by force temporarily"
1379 at_max_set 600 mds ost client
1383 if [ -z "$ATOLDBASE" ]; then
1384 local at_history=$(do_facet mds "find /sys/ -name at_history")
1385 [ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
1386 ATOLDBASE=$(do_facet mds "cat $at_history")
1387 # speed up the timebase so we can check decreasing AT
1388 do_facet mds "echo 8 >> $at_history"
1389 do_facet ost1 "echo 8 >> $at_history"
1393 test_65a() #bug 3055
1395 at_start || return 0
1396 $LCTL dk > /dev/null
1398 sysctl -w lnet.debug="+other"
1399 # slow down a request
1400 do_facet mds sysctl -w lustre.fail_val=30000
1401 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1402 do_facet mds sysctl -w lustre.fail_loc=0x8000050a
1403 createmany -o $DIR/$tfile 10 > /dev/null
1404 unlinkmany $DIR/$tfile 10 > /dev/null
1405 # check for log message
1406 $LCTL dk | grep "Early reply #" || error "No early reply"
1407 # client should show 30s estimates
1408 grep portal $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts
1410 grep portal $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts
1412 run_test 65a "AT: verify early replies"
1414 test_65b() #bug 3055
1416 at_start || return 0
1419 sysctl -w lnet.debug="+other"
1420 $LCTL dk > /dev/null
1421 # slow down bulk i/o
1422 do_facet ost1 sysctl -w lustre.fail_val=30
1423 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1424 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1427 lfs setstripe $DIR/$tfile --index=0 --count=1
1428 # force some real bulk transfer
1429 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1431 do_facet ost1 sysctl -w lustre.fail_loc=0
1432 # check for log message
1433 $LCTL dk | grep "Early reply #" || error "No early reply"
1435 # client should show 30s estimates
1436 grep portal $LPROC/osc/${FSNAME}-OST0000-osc-*/timeouts
1438 run_test 65b "AT: verify early replies on packed reply / bulk"
1440 test_66a() #bug 3055
1442 at_start || return 0
1443 grep "portal 12" $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts
1444 # adjust 5s at a time so no early reply is sent (within deadline)
1445 do_facet mds "sysctl -w lustre.fail_val=5000"
1446 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1447 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1448 createmany -o $DIR/$tfile 20 > /dev/null
1449 unlinkmany $DIR/$tfile 20 > /dev/null
1450 grep "portal 12" $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts
1451 do_facet mds "sysctl -w lustre.fail_val=10000"
1452 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1453 createmany -o $DIR/$tfile 20 > /dev/null
1454 unlinkmany $DIR/$tfile 20 > /dev/null
1455 grep "portal 12" $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts
1456 do_facet mds "sysctl -w lustre.fail_loc=0"
1458 createmany -o $DIR/$tfile 20 > /dev/null
1459 unlinkmany $DIR/$tfile 20 > /dev/null
1460 grep portal $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts | grep "portal 12"
1461 CUR=$(awk '/portal 12/ {print $5}' $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts)
1462 WORST=$(awk '/portal 12/ {print $7}' $LPROC/mdc/${FSNAME}-MDT0000-mdc-*/timeouts)
1463 echo "Current MDT timeout $CUR, worst $WORST"
1464 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1466 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1468 test_66b() #bug 3055
1470 at_start || return 0
1471 ORIG=$(awk '/network/ {print $4}' $LPROC/mdc/${FSNAME}-*/timeouts)
1472 sysctl -w lustre.fail_val=$(($ORIG + 5))
1473 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1474 sysctl -w lustre.fail_loc=0x50c
1475 ls $DIR/$tfile > /dev/null 2>&1
1476 sysctl -w lustre.fail_loc=0
1477 CUR=$(awk '/network/ {print $4}' $LPROC/mdc/${FSNAME}-*/timeouts)
1478 WORST=$(awk '/network/ {print $6}' $LPROC/mdc/${FSNAME}-*/timeouts)
1479 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1480 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1482 run_test 66b "AT: verify net latency adjusts"
1484 test_67a() #bug 3055
1486 at_start || return 0
1487 CONN1=$(awk '/_connect/ {total+=$2} END {print total}' $LPROC/osc/*/stats)
1488 # sleeping threads may drive values above this
1489 do_facet ost1 "sysctl -w lustre.fail_val=400"
1490 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1491 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1492 createmany -o $DIR/$tfile 20 > /dev/null
1493 unlinkmany $DIR/$tfile 20 > /dev/null
1494 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1495 CONN2=$(awk '/_connect/ {total+=$2} END {print total}' $LPROC/osc/*/stats)
1496 ATTEMPTS=$(($CONN2 - $CONN1))
1497 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1498 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1501 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1503 test_67b() #bug 3055
1505 at_start || return 0
1506 CONN1=$(awk '/_connect/ {total+=$2} END {print total}' $LPROC/osc/*/stats)
1507 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1508 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1509 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1510 cp /etc/profile $DIR/$tfile || error "cp failed"
1512 cat $LPROC/ost/OSS/ost_create/timeouts
1514 CONN2=$(awk '/_connect/ {total+=$2} END {print total}' $LPROC/osc/*/stats)
1515 ATTEMPTS=$(($CONN2 - $CONN1))
1516 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1517 # do it again; should not timeout
1518 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1519 cp /etc/profile $DIR/$tfile || error "cp failed"
1520 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1522 cat $LPROC/ost/OSS/ost_create/timeouts
1523 CONN3=$(awk '/_connect/ {total+=$2} END {print total}' $LPROC/osc/*/stats)
1524 ATTEMPTS=$(($CONN3 - $CONN2))
1525 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1526 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1529 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1531 test_68 () #bug 13813
1533 at_start || return 0
1534 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1535 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1536 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1537 echo $TIMEOUT >> $ldlm_enqueue_min
1538 rm -f $DIR/${tfile}_[1-2]
1539 lfs setstripe $DIR/$tfile --index=0 --count=1
1540 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1541 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1542 sysctl -w lustre.fail_loc=0x80000312
1543 cp /etc/profile $DIR/${tfile}_1 || error "1st cp failed $?"
1544 sysctl -w lustre.fail_val=$((TIMEOUT * 3 / 2))
1545 sysctl -w lustre.fail_loc=0x80000312
1546 cp /etc/profile $DIR/${tfile}_2 || error "2nd cp failed $?"
1547 sysctl -w lustre.fail_loc=0
1548 echo $ENQ_MIN >> $ldlm_enqueue_min
1551 run_test 68 "AT: verify slowing locks"
1553 if [ -n "$ATOLDBASE" ]; then
1554 at_history=$(do_facet mds "find /sys/ -name at_history")
1555 do_facet mds "echo $ATOLDBASE >> $at_history" || true
1556 do_facet ost1 "echo $ATOLDBASE >> $at_history" || true
1559 if [ $AT_MAX_SET -ne 0 ]; then
1560 echo "restore AT status to be disabled"
1561 at_max_set 0 mds ost client
1564 # end of AT tests includes above lines
1566 equals_msg `basename $0`: test complete, cleaning up
1567 check_and_cleanup_lustre
1568 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true