Whamcloud - gitweb
b=16509 port recovery ending tests to master
[fs/lustre-release.git] / lustre / tests / replay-single.sh
1 #!/bin/bash
2
3 set -e
4 #set -v
5
6 #
7 # This test needs to be run on the client
8 #
9 SAVE_PWD=$PWD
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
11 SETUP=${SETUP:-}
12 CLEANUP=${CLEANUP:-}
13 . $LUSTRE/tests/test-framework.sh
14 init_test_env $@
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 init_logging
17 CHECK_GRANT=${CHECK_GRANT:-"yes"}
18 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
19
20 require_dsh_mds || exit 0
21
22 # Skip these tests
23 # bug number:  17466 18857
24 ALWAYS_EXCEPT="61d   33a 33b    $REPLAY_SINGLE_EXCEPT"
25
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"
28
29 build_test_filter
30
31 check_and_setup_lustre
32
33 mkdir -p $DIR
34
35 assert_DIR
36 rm -rf $DIR/[df][0-9]*
37
38 test_0a() {     # was test_0
39     sleep 10
40     mkdir $DIR/$tfile
41     replay_barrier $SINGLEMDS
42     fail $SINGLEMDS
43     rmdir $DIR/$tfile
44 }
45 run_test 0a "empty replay"
46
47 test_0b() {
48     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
49
50     # this test attempts to trigger a race in the precreation code,
51     # and must run before any other objects are created on the filesystem
52     fail ost1
53     createmany -o $DIR/$tfile 20 || return 1
54     unlinkmany $DIR/$tfile 20 || return 2
55 }
56 run_test 0b "ensure object created after recover exists. (3284)"
57
58 seq_set_width()
59 {
60     local mds=$1
61     local width=$2
62     lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
63 }
64
65 seq_get_width()
66 {
67     local mds=$1
68     lctl get_param -n seq.cli-srv-$mds-mdc-*.width
69 }
70
71 # This test should pass for single-mds and multi-mds configs.
72 # But for different configurations it tests different things.
73 #
74 # single-mds
75 # ----------
76 # (1) fld_create replay should happen;
77 #
78 # (2) fld_create replay should not return -EEXISTS, if it does
79 # this means sequence manager recovery code is buggy and allocated
80 # same sequence two times after recovery.
81 #
82 # multi-mds
83 # ---------
84 # (1) fld_create replay may not happen, because its home MDS is
85 # MDS2 which is not involved to revovery;
86 #
87 # (2) as fld_create does not happen on MDS1, it does not make any
88 # problem.
89 test_0c() {
90     local label=`mdsdevlabel 1`
91     [ -z "$label" ] && echo "No label for mds1" && return 1
92
93     replay_barrier $SINGLEMDS
94     local sw=`seq_get_width $label`
95
96     # make seq manager switch to next sequence each
97     # time as new fid is needed.
98     seq_set_width $label 1
99
100     # make sure that fld has created at least one new
101     # entry on server
102     touch $DIR/$tfile || return 2
103     seq_set_width $label $sw
104
105     # fail $SINGLEMDS and start recovery, replay RPCs, etc.
106     fail $SINGLEMDS
107
108     # wait for recovery finish
109     sleep 10
110     df $MOUNT
111
112     # flush fld cache and dentry cache to make it lookup
113     # created entry instead of revalidating existent one
114     umount $MOUNT
115     zconf_mount `hostname` $MOUNT
116
117     # issue lookup which should call fld lookup which
118     # should fail if client did not replay fld create
119     # correctly and server has no fld entry
120     touch $DIR/$tfile || return 3
121     rm $DIR/$tfile || return 4
122 }
123 start_full_debug_logging
124 run_test 0c "fld create"
125 stop_full_debug_logging
126
127 test_0d() {
128     replay_barrier $SINGLEMDS
129     umount $MOUNT
130     facet_failover $SINGLEMDS
131     zconf_mount `hostname` $MOUNT || error "mount fails"
132     client_up || error "post-failover df failed"
133 }
134 run_test 0d "expired recovery with no clients"
135
136 test_1() {
137     replay_barrier $SINGLEMDS
138     mcreate $DIR/$tfile
139     fail $SINGLEMDS
140     $CHECKSTAT -t file $DIR/$tfile || return 1
141     rm $DIR/$tfile
142 }
143 run_test 1 "simple create"
144
145 test_2a() {
146     replay_barrier $SINGLEMDS
147     touch $DIR/$tfile
148     fail $SINGLEMDS
149     $CHECKSTAT -t file $DIR/$tfile || return 1
150     rm $DIR/$tfile
151 }
152 run_test 2a "touch"
153
154 test_2b() {
155     mcreate $DIR/$tfile
156     replay_barrier $SINGLEMDS
157     touch $DIR/$tfile
158     fail $SINGLEMDS
159     $CHECKSTAT -t file $DIR/$tfile || return 1
160     rm $DIR/$tfile
161 }
162 run_test 2b "touch"
163
164 test_3a() {
165     local file=$DIR/$tfile
166     replay_barrier $SINGLEMDS
167     mcreate $file
168     openfile -f O_DIRECTORY $file
169     fail $SINGLEMDS
170     $CHECKSTAT -t file $file || return 2
171     rm $file
172 }
173 run_test 3a "replay failed open(O_DIRECTORY)"
174
175 test_3b() {
176     replay_barrier $SINGLEMDS
177 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
178     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
179     touch $DIR/$tfile
180     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
181     fail $SINGLEMDS
182     $CHECKSTAT -t file $DIR/$tfile && return 2
183     return 0
184 }
185 run_test 3b "replay failed open -ENOMEM"
186
187 test_3c() {
188     replay_barrier $SINGLEMDS
189 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
190     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
191     touch $DIR/$tfile
192     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
193     fail $SINGLEMDS
194
195     $CHECKSTAT -t file $DIR/$tfile && return 2
196     return 0
197 }
198 run_test 3c "replay failed open -ENOMEM"
199
200 test_4a() {     # was test_4
201     replay_barrier $SINGLEMDS
202     for i in `seq 10`; do
203         echo "tag-$i" > $DIR/$tfile-$i
204     done
205     fail $SINGLEMDS
206     for i in `seq 10`; do
207       grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
208     done
209 }
210 run_test 4a "|x| 10 open(O_CREAT)s"
211
212 test_4b() {
213     replay_barrier $SINGLEMDS
214     rm -rf $DIR/$tfile-*
215     fail $SINGLEMDS
216     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
217 }
218 run_test 4b "|x| rm 10 files"
219
220 # The idea is to get past the first block of precreated files on both
221 # osts, and then replay.
222 test_5() {
223     replay_barrier $SINGLEMDS
224     for i in `seq 220`; do
225         echo "tag-$i" > $DIR/$tfile-$i
226     done
227     fail $SINGLEMDS
228     for i in `seq 220`; do
229       grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
230     done
231     rm -rf $DIR/$tfile-*
232     sleep 3
233     # waiting for commitment of removal
234 }
235 run_test 5 "|x| 220 open(O_CREAT)"
236
237
238 test_6a() {     # was test_6
239     mkdir -p $DIR/$tdir
240     replay_barrier $SINGLEMDS
241     mcreate $DIR/$tdir/$tfile
242     fail $SINGLEMDS
243     $CHECKSTAT -t dir $DIR/$tdir || return 1
244     $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
245     sleep 2
246     # waiting for log process thread
247 }
248 run_test 6a "mkdir + contained create"
249
250 test_6b() {
251     mkdir -p $DIR/$tdir
252     replay_barrier $SINGLEMDS
253     rm -rf $DIR/$tdir
254     fail $SINGLEMDS
255     $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
256 }
257 run_test 6b "|X| rmdir"
258
259 test_7() {
260     mkdir -p $DIR/$tdir
261     replay_barrier $SINGLEMDS
262     mcreate $DIR/$tdir/$tfile
263     fail $SINGLEMDS
264     $CHECKSTAT -t dir $DIR/$tdir || return 1
265     $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
266     rm -fr $DIR/$tdir
267 }
268 run_test 7 "mkdir |X| contained create"
269
270 test_8() {
271     # make sure no side-effect from previous test.
272     rm -f $DIR/$tfile
273     replay_barrier $SINGLEMDS
274     multiop_bg_pause $DIR/$tfile mo_c || return 4
275     MULTIPID=$!
276     fail $SINGLEMDS
277     ls $DIR/$tfile
278     $CHECKSTAT -t file $DIR/$tfile || return 1
279     kill -USR1 $MULTIPID || return 2
280     wait $MULTIPID || return 3
281     rm $DIR/$tfile
282 }
283 run_test 8 "creat open |X| close"
284
285 test_9() {
286     replay_barrier $SINGLEMDS
287     mcreate $DIR/$tfile
288     local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
289     fail $SINGLEMDS
290     local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
291
292     echo " old_inum == $old_inum, new_inum == $new_inum"
293     if [ $old_inum -eq $new_inum  ] ;
294     then
295         echo " old_inum and new_inum match"
296     else
297         echo "!!!! old_inum and new_inum NOT match"
298         return 1
299     fi
300     rm $DIR/$tfile
301 }
302 run_test 9  "|X| create (same inum/gen)"
303
304 test_10() {
305     mcreate $DIR/$tfile
306     replay_barrier $SINGLEMDS
307     mv $DIR/$tfile $DIR/$tfile-2
308     rm -f $DIR/$tfile
309     fail $SINGLEMDS
310     $CHECKSTAT $DIR/$tfile && return 1
311     $CHECKSTAT $DIR/$tfile-2 ||return 2
312     rm $DIR/$tfile-2
313     return 0
314 }
315 run_test 10 "create |X| rename unlink"
316
317 test_11() {
318     mcreate $DIR/$tfile
319     echo "old" > $DIR/$tfile
320     mv $DIR/$tfile $DIR/$tfile-2
321     replay_barrier $SINGLEMDS
322     echo "new" > $DIR/$tfile
323     grep new $DIR/$tfile
324     grep old $DIR/$tfile-2
325     fail $SINGLEMDS
326     grep new $DIR/$tfile || return 1
327     grep old $DIR/$tfile-2 || return 2
328 }
329 run_test 11 "create open write rename |X| create-old-name read"
330
331 test_12() {
332     mcreate $DIR/$tfile
333     multiop_bg_pause $DIR/$tfile o_tSc || return 3
334     pid=$!
335     rm -f $DIR/$tfile
336     replay_barrier $SINGLEMDS
337     kill -USR1 $pid
338     wait $pid || return 1
339
340     fail $SINGLEMDS
341     [ -e $DIR/$tfile ] && return 2
342     return 0
343 }
344 run_test 12 "open, unlink |X| close"
345
346
347 # 1777 - replay open after committed chmod that would make
348 #        a regular open a failure
349 test_13() {
350     mcreate $DIR/$tfile
351     multiop_bg_pause $DIR/$tfile O_wc || return 3
352     pid=$!
353     chmod 0 $DIR/$tfile
354     $CHECKSTAT -p 0 $DIR/$tfile
355     replay_barrier $SINGLEMDS
356     fail $SINGLEMDS
357     kill -USR1 $pid
358     wait $pid || return 1
359
360     $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
361     rm $DIR/$tfile || return 4
362     return 0
363 }
364 run_test 13 "open chmod 0 |x| write close"
365
366 test_14() {
367     multiop_bg_pause $DIR/$tfile O_tSc || return 4
368     pid=$!
369     rm -f $DIR/$tfile
370     replay_barrier $SINGLEMDS
371     kill -USR1 $pid || return 1
372     wait $pid || return 2
373
374     fail $SINGLEMDS
375     [ -e $DIR/$tfile ] && return 3
376     return 0
377 }
378 run_test 14 "open(O_CREAT), unlink |X| close"
379
380 test_15() {
381     multiop_bg_pause $DIR/$tfile O_tSc || return 5
382     pid=$!
383     rm -f $DIR/$tfile
384     replay_barrier $SINGLEMDS
385     touch $DIR/g11 || return 1
386     kill -USR1 $pid
387     wait $pid || return 2
388
389     fail $SINGLEMDS
390     [ -e $DIR/$tfile ] && return 3
391     touch $DIR/h11 || return 4
392     return 0
393 }
394 run_test 15 "open(O_CREAT), unlink |X|  touch new, close"
395
396
397 test_16() {
398     replay_barrier $SINGLEMDS
399     mcreate $DIR/$tfile
400     munlink $DIR/$tfile
401     mcreate $DIR/$tfile-2
402     fail $SINGLEMDS
403     [ -e $DIR/$tfile ] && return 1
404     [ -e $DIR/$tfile-2 ] || return 2
405     munlink $DIR/$tfile-2 || return 3
406 }
407 run_test 16 "|X| open(O_CREAT), unlink, touch new,  unlink new"
408
409 test_17() {
410     replay_barrier $SINGLEMDS
411     multiop_bg_pause $DIR/$tfile O_c || return 4
412     pid=$!
413     fail $SINGLEMDS
414     kill -USR1 $pid || return 1
415     wait $pid || return 2
416     $CHECKSTAT -t file $DIR/$tfile || return 3
417     rm $DIR/$tfile
418 }
419 run_test 17 "|X| open(O_CREAT), |replay| close"
420
421 test_18() {
422     replay_barrier $SINGLEMDS
423     multiop_bg_pause $DIR/$tfile O_tSc || return 8
424     pid=$!
425     rm -f $DIR/$tfile
426     touch $DIR/$tfile-2 || return 1
427     echo "pid: $pid will close"
428     kill -USR1 $pid
429     wait $pid || return 2
430
431     fail $SINGLEMDS
432     [ -e $DIR/$tfile ] && return 3
433     [ -e $DIR/$tfile-2 ] || return 4
434     # this touch frequently fails
435     touch $DIR/$tfile-3 || return 5
436     munlink $DIR/$tfile-2 || return 6
437     munlink $DIR/$tfile-3 || return 7
438     return 0
439 }
440 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
441
442 # bug 1855 (a simpler form of test_11 above)
443 test_19() {
444     replay_barrier $SINGLEMDS
445     mcreate $DIR/$tfile
446     echo "old" > $DIR/$tfile
447     mv $DIR/$tfile $DIR/$tfile-2
448     grep old $DIR/$tfile-2
449     fail $SINGLEMDS
450     grep old $DIR/$tfile-2 || return 2
451 }
452 run_test 19 "|X| mcreate, open, write, rename "
453
454 test_20a() {    # was test_20
455     replay_barrier $SINGLEMDS
456     multiop_bg_pause $DIR/$tfile O_tSc || return 3
457     pid=$!
458     rm -f $DIR/$tfile
459
460     fail $SINGLEMDS
461     kill -USR1 $pid
462     wait $pid || return 1
463     [ -e $DIR/$tfile ] && return 2
464     return 0
465 }
466 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
467
468 test_20b() { # bug 10480
469     BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
470
471     dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
472     pid=$!
473     while [ ! -e $DIR/$tfile ] ; do
474         usleep 60                           # give dd a chance to start
475     done
476
477     lfs getstripe $DIR/$tfile || return 1
478     rm -f $DIR/$tfile || return 2       # make it an orphan
479     mds_evict_client
480     client_up || client_up || true    # reconnect
481
482     fail $SINGLEMDS                            # start orphan recovery
483     wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
484     wait_mds_ost_sync || return 3
485     AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
486     log "before $BEFOREUSED, after $AFTERUSED"
487     [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
488         error "after $AFTERUSED > before $BEFOREUSED"
489     return 0
490 }
491 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
492
493 test_20c() { # bug 10480
494     multiop_bg_pause $DIR/$tfile Ow_c || return 1
495     pid=$!
496
497     ls -la $DIR/$tfile
498
499     mds_evict_client
500     client_up || client_up || true    # reconnect
501
502     kill -USR1 $pid
503     wait $pid || return 1
504     [ -s $DIR/$tfile ] || error "File was truncated"
505
506     return 0
507 }
508 run_test 20c "check that client eviction does not affect file content"
509
510 test_21() {
511     replay_barrier $SINGLEMDS
512     multiop_bg_pause $DIR/$tfile O_tSc || return 5
513     pid=$!
514     rm -f $DIR/$tfile
515     touch $DIR/g11 || return 1
516
517     fail $SINGLEMDS
518     kill -USR1 $pid
519     wait $pid || return 2
520     [ -e $DIR/$tfile ] && return 3
521     touch $DIR/h11 || return 4
522     return 0
523 }
524 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
525
526 test_22() {
527     multiop_bg_pause $DIR/$tfile O_tSc || return 3
528     pid=$!
529
530     replay_barrier $SINGLEMDS
531     rm -f $DIR/$tfile
532
533     fail $SINGLEMDS
534     kill -USR1 $pid
535     wait $pid || return 1
536     [ -e $DIR/$tfile ] && return 2
537     return 0
538 }
539 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
540
541 test_23() {
542     multiop_bg_pause $DIR/$tfile O_tSc || return 5
543     pid=$!
544
545     replay_barrier $SINGLEMDS
546     rm -f $DIR/$tfile
547     touch $DIR/g11 || return 1
548
549     fail $SINGLEMDS
550     kill -USR1 $pid
551     wait $pid || return 2
552     [ -e $DIR/$tfile ] && return 3
553     touch $DIR/h11 || return 4
554     return 0
555 }
556 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
557
558 test_24() {
559     multiop_bg_pause $DIR/$tfile O_tSc || return 3
560     pid=$!
561
562     replay_barrier $SINGLEMDS
563     fail $SINGLEMDS
564     rm -f $DIR/$tfile
565     kill -USR1 $pid
566     wait $pid || return 1
567     [ -e $DIR/$tfile ] && return 2
568     return 0
569 }
570 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
571
572 test_25() {
573     multiop_bg_pause $DIR/$tfile O_tSc || return 3
574     pid=$!
575     rm -f $DIR/$tfile
576
577     replay_barrier $SINGLEMDS
578     fail $SINGLEMDS
579     kill -USR1 $pid
580     wait $pid || return 1
581     [ -e $DIR/$tfile ] && return 2
582     return 0
583 }
584 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
585
586 test_26() {
587     replay_barrier $SINGLEMDS
588     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
589     pid1=$!
590     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
591     pid2=$!
592     rm -f $DIR/$tfile-1
593     rm -f $DIR/$tfile-2
594     kill -USR1 $pid2
595     wait $pid2 || return 1
596
597     fail $SINGLEMDS
598     kill -USR1 $pid1
599     wait $pid1 || return 2
600     [ -e $DIR/$tfile-1 ] && return 3
601     [ -e $DIR/$tfile-2 ] && return 4
602     return 0
603 }
604 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
605
606 test_27() {
607     replay_barrier $SINGLEMDS
608     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
609     pid1=$!
610     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
611     pid2=$!
612     rm -f $DIR/$tfile-1
613     rm -f $DIR/$tfile-2
614
615     fail $SINGLEMDS
616     kill -USR1 $pid1
617     wait $pid1 || return 1
618     kill -USR1 $pid2
619     wait $pid2 || return 2
620     [ -e $DIR/$tfile-1 ] && return 3
621     [ -e $DIR/$tfile-2 ] && return 4
622     return 0
623 }
624 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
625
626 test_28() {
627     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
628     pid1=$!
629     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
630     pid2=$!
631     replay_barrier $SINGLEMDS
632     rm -f $DIR/$tfile-1
633     rm -f $DIR/$tfile-2
634     kill -USR1 $pid2
635     wait $pid2 || return 1
636
637     fail $SINGLEMDS
638     kill -USR1 $pid1
639     wait $pid1 || return 2
640     [ -e $DIR/$tfile-1 ] && return 3
641     [ -e $DIR/$tfile-2 ] && return 4
642     return 0
643 }
644 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
645
646 test_29() {
647     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
648     pid1=$!
649     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
650     pid2=$!
651     replay_barrier $SINGLEMDS
652     rm -f $DIR/$tfile-1
653     rm -f $DIR/$tfile-2
654
655     fail $SINGLEMDS
656     kill -USR1 $pid1
657     wait $pid1 || return 1
658     kill -USR1 $pid2
659     wait $pid2 || return 2
660     [ -e $DIR/$tfile-1 ] && return 3
661     [ -e $DIR/$tfile-2 ] && return 4
662     return 0
663 }
664 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
665
666 test_30() {
667     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
668     pid1=$!
669     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
670     pid2=$!
671     rm -f $DIR/$tfile-1
672     rm -f $DIR/$tfile-2
673
674     replay_barrier $SINGLEMDS
675     fail $SINGLEMDS
676     kill -USR1 $pid1
677     wait $pid1 || return 1
678     kill -USR1 $pid2
679     wait $pid2 || return 2
680     [ -e $DIR/$tfile-1 ] && return 3
681     [ -e $DIR/$tfile-2 ] && return 4
682     return 0
683 }
684 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
685
686 test_31() {
687     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
688     pid1=$!
689     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
690     pid2=$!
691     rm -f $DIR/$tfile-1
692
693     replay_barrier $SINGLEMDS
694     rm -f $DIR/$tfile-2
695     fail $SINGLEMDS
696     kill -USR1 $pid1
697     wait $pid1 || return 1
698     kill -USR1 $pid2
699     wait $pid2 || return 2
700     [ -e $DIR/$tfile-1 ] && return 3
701     [ -e $DIR/$tfile-2 ] && return 4
702     return 0
703 }
704 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
705
706 # tests for bug 2104; completion without crashing is success.  The close is
707 # stale, but we always return 0 for close, so the app never sees it.
708 test_32() {
709     multiop_bg_pause $DIR/$tfile O_c || return 2
710     pid1=$!
711     multiop_bg_pause $DIR/$tfile O_c || return 3
712     pid2=$!
713     mds_evict_client
714     client_up || client_up || return 1
715     kill -USR1 $pid1
716     kill -USR1 $pid2
717     wait $pid1 || return 4
718     wait $pid2 || return 5
719     return 0
720 }
721 run_test 32 "close() notices client eviction; close() after client eviction"
722
723 test_33a() {
724     createmany -o $DIR/$tfile-%d 10
725     replay_barrier_nosync $SINGLEMDS
726     fail_abort $SINGLEMDS
727     # recreate shouldn't fail
728     createmany -o $DIR/$tfile--%d 10 || return 1
729     rm $DIR/$tfile-* -f
730     return 0
731 }
732 run_test 33a "fid seq shouldn't be reused after abort recovery"
733
734 test_33b() {
735     #define OBD_FAIL_SEQ_ALLOC                          0x1311
736     do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
737
738     createmany -o $DIR/$tfile-%d 10
739     replay_barrier_nosync $SINGLEMDS
740     fail_abort $SINGLEMDS
741     # recreate shouldn't fail
742     createmany -o $DIR/$tfile--%d 10 || return 1
743     rm $DIR/$tfile-* -f
744     return 0
745 }
746 run_test 33b "test fid seq allocation"
747
748 test_34() {
749     multiop_bg_pause $DIR/$tfile O_c || return 2
750     pid=$!
751     rm -f $DIR/$tfile
752
753     replay_barrier $SINGLEMDS
754     fail_abort $SINGLEMDS
755     kill -USR1 $pid
756     wait $pid || return 3
757     [ -e $DIR/$tfile ] && return 1
758     sync
759     return 0
760 }
761 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
762
763 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
764 test_35() {
765     touch $DIR/$tfile
766
767 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
768     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
769     rm -f $DIR/$tfile &
770     sleep 1
771     sync
772     sleep 1
773     # give a chance to remove from MDS
774     fail_abort $SINGLEMDS
775     $CHECKSTAT -t file $DIR/$tfile && return 1 || true
776 }
777 run_test 35 "test recovery from llog for unlink op"
778
779 # b=2432 resent cancel after replay uses wrong cookie,
780 # so don't resend cancels
781 test_36() {
782     replay_barrier $SINGLEMDS
783     touch $DIR/$tfile
784     checkstat $DIR/$tfile
785     facet_failover $SINGLEMDS
786     cancel_lru_locks mdc
787     if dmesg | grep "unknown lock cookie"; then
788         echo "cancel after replay failed"
789         return 1
790     fi
791 }
792 run_test 36 "don't resend cancel"
793
794 # b=2368
795 # directory orphans can't be unlinked from PENDING directory
796 test_37() {
797     rmdir $DIR/$tfile 2>/dev/null
798     multiop_bg_pause $DIR/$tfile dD_c || return 2
799     pid=$!
800     rmdir $DIR/$tfile
801
802     replay_barrier $SINGLEMDS
803     # clear the dmesg buffer so we only see errors from this recovery
804     dmesg -c >/dev/null
805     fail_abort $SINGLEMDS
806     kill -USR1 $pid
807     dmesg | grep  "mds_unlink_orphan.*error .* unlinking orphan" && return 1
808     wait $pid || return 3
809     sync
810     return 0
811 }
812 start_full_debug_logging
813 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
814 stop_full_debug_logging
815
816 test_38() {
817     createmany -o $DIR/$tfile-%d 800
818     unlinkmany $DIR/$tfile-%d 0 400
819     replay_barrier $SINGLEMDS
820     fail $SINGLEMDS
821     unlinkmany $DIR/$tfile-%d 400 400
822     sleep 2
823     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
824 }
825 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
826
827 test_39() { # bug 4176
828     createmany -o $DIR/$tfile-%d 800
829     replay_barrier $SINGLEMDS
830     unlinkmany $DIR/$tfile-%d 0 400
831     fail $SINGLEMDS
832     unlinkmany $DIR/$tfile-%d 400 400
833     sleep 2
834     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
835 }
836 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
837
838 count_ost_writes() {
839     lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
840 }
841
842 #b=2477,2532
843 test_40(){
844     $LCTL mark multiop $MOUNT/$tfile OS_c
845     multiop $MOUNT/$tfile OS_c  &
846     PID=$!
847     writeme -s $MOUNT/${tfile}-2 &
848     WRITE_PID=$!
849     sleep 1
850     facet_failover $SINGLEMDS
851 #define OBD_FAIL_MDS_CONNECT_NET         0x117
852     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
853     kill -USR1 $PID
854     stat1=`count_ost_writes`
855     sleep $TIMEOUT
856     stat2=`count_ost_writes`
857     echo "$stat1, $stat2"
858     if [ $stat1 -lt $stat2 ]; then
859        echo "writes continuing during recovery"
860        RC=0
861     else
862        echo "writes not continuing during recovery, bug 2477"
863        RC=4
864     fi
865     echo "waiting for writeme $WRITE_PID"
866     kill $WRITE_PID
867     wait $WRITE_PID
868
869     echo "waiting for multiop $PID"
870     wait $PID || return 2
871     do_facet client munlink $MOUNT/$tfile  || return 3
872     do_facet client munlink $MOUNT/${tfile}-2  || return 3
873     return $RC
874 }
875 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
876
877
878 #b=2814
879 # make sure that a read to one osc doesn't try to double-unlock its page just
880 # because another osc is invalid.  trigger_group_io used to mistakenly return
881 # an error if any oscs were invalid even after having successfully put rpcs
882 # on valid oscs.  This was fatal if the caller was ll_readpage who unlocked
883 # the page, guarnateeing that the unlock from the RPC completion would
884 # assert on trying to unlock the unlocked page.
885 test_41() {
886     [ $OSTCOUNT -lt 2 ] && \
887         skip_env "skipping test 41: we don't have a second OST to test with" && \
888         return
889
890     local f=$MOUNT/$tfile
891     # make sure the start of the file is ost1
892     lfs setstripe $f -s $((128 * 1024)) -i 0
893     do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
894     cancel_lru_locks osc
895     # fail ost2 and read from ost1
896     local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
897     local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
898         grep $mdtosc | awk '{print $1}')
899     [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
900     do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
901     do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
902     do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
903     return 0
904 }
905 run_test 41 "read from a valid osc while other oscs are invalid"
906
907 # test MDS recovery after ost failure
908 test_42() {
909     blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
910     createmany -o $DIR/$tfile-%d 800
911     replay_barrier ost1
912     unlinkmany $DIR/$tfile-%d 0 400
913     debugsave
914     lctl set_param debug=-1
915     facet_failover ost1
916
917     # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
918     #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
919     #[ $blocks_after -lt $blocks ] || return 1
920     echo wait for MDS to timeout and recover
921     sleep $((TIMEOUT * 2))
922     debugrestore
923     unlinkmany $DIR/$tfile-%d 400 400
924     $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
925 }
926 run_test 42 "recovery after ost failure"
927
928 # timeout in MDS/OST recovery RPC will LBUG MDS
929 test_43() { # bug 2530
930     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
931
932     replay_barrier $SINGLEMDS
933
934     # OBD_FAIL_OST_CREATE_NET 0x204
935     do_facet ost1 "lctl set_param fail_loc=0x80000204"
936     fail $SINGLEMDS
937     sleep 10
938     do_facet ost1 "lctl set_param fail_loc=0"
939
940     return 0
941 }
942 run_test 43 "mds osc import failure during recovery; don't LBUG"
943
944 test_44a() { # was test_44
945     local at_max_saved=0
946
947     mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
948     [ "$mdcdev" ] || return 2
949     [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
950
951     # adaptive timeouts slow this way down
952     if at_is_enabled; then
953         at_max_saved=$(at_max_get mds)
954         at_max_set 40 mds
955     fi
956
957     for i in `seq 1 10`; do
958         echo "$i of 10 ($(date +%s))"
959         do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
960         #define OBD_FAIL_TGT_CONN_RACE     0x701
961         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
962         # lctl below may fail, it is valid case
963         $LCTL --device $mdcdev recover
964         df $MOUNT
965     done
966     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
967     [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
968     return 0
969 }
970 run_test 44a "race in target handle connect"
971
972 test_44b() {
973     local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
974     [ "$mdcdev" ] || return 2
975     [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
976
977     for i in `seq 1 10`; do
978         echo "$i of 10 ($(date +%s))"
979         do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
980         #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
981         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
982         # lctl below may fail, it is valid case
983         $LCTL --device $mdcdev recover
984         df $MOUNT
985     done
986     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
987     return 0
988 }
989 run_test 44b "race in target handle connect"
990
991 # Handle failed close
992 test_45() {
993     mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
994     [ "$mdcdev" ] || return 2
995     [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
996
997     $LCTL --device $mdcdev recover || return 6 
998
999     multiop_bg_pause $DIR/$tfile O_c || return 1
1000     pid=$!
1001
1002     # This will cause the CLOSE to fail before even
1003     # allocating a reply buffer
1004     $LCTL --device $mdcdev deactivate || return 4
1005
1006     # try the close
1007     kill -USR1 $pid
1008     wait $pid || return 1
1009
1010     $LCTL --device $mdcdev activate || return 5
1011     sleep 1
1012
1013     $CHECKSTAT -t file $DIR/$tfile || return 2
1014     return 0
1015 }
1016 run_test 45 "Handle failed close"
1017
1018 test_46() {
1019     dmesg -c >/dev/null
1020     drop_reply "touch $DIR/$tfile"
1021     fail $SINGLEMDS
1022     # ironically, the previous test, 45, will cause a real forced close,
1023     # so just look for one for this test
1024     dmesg | grep -i "force closing client file handle for $tfile" && return 1
1025     return 0
1026 }
1027 run_test 46 "Don't leak file handle after open resend (3325)"
1028
1029 test_47() { # bug 2824
1030     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1031
1032     # create some files to make sure precreate has been done on all
1033     # OSTs. (just in case this test is run independently)
1034     createmany -o $DIR/$tfile 20  || return 1
1035
1036     # OBD_FAIL_OST_CREATE_NET 0x204
1037     fail ost1
1038     do_facet ost1 "lctl set_param fail_loc=0x80000204"
1039     client_up || return 2
1040
1041     # let the MDS discover the OST failure, attempt to recover, fail
1042     # and recover again.
1043     sleep $((3 * TIMEOUT))
1044
1045     # Without 2824, this createmany would hang
1046     createmany -o $DIR/$tfile 20 || return 3
1047     unlinkmany $DIR/$tfile 20 || return 4
1048
1049     do_facet ost1 "lctl set_param fail_loc=0"
1050     return 0
1051 }
1052 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1053
1054 test_48() {
1055     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1056     [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1057
1058     replay_barrier $SINGLEMDS
1059     createmany -o $DIR/$tfile 20  || return 1
1060     # OBD_FAIL_OST_EROFS 0x216
1061     facet_failover $SINGLEMDS
1062     do_facet ost1 "lctl set_param fail_loc=0x80000216"
1063     client_up || return 2
1064
1065     createmany -o $DIR/$tfile 20 20 || return 2
1066     unlinkmany $DIR/$tfile 40 || return 3
1067     return 0
1068 }
1069 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1070
1071 test_50() {
1072     local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc) 
1073     local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1074         grep $mdtosc | awk '{print $1}')
1075     [ "$oscdev" ] || return 1
1076     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1077     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1078     # give the mds_lov_sync threads a chance to run
1079     sleep 5
1080 }
1081 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1082
1083 # b3764 timed out lock replay
1084 test_52() {
1085     touch $DIR/$tfile
1086     cancel_lru_locks mdc
1087
1088     multiop $DIR/$tfile s || return 1
1089     replay_barrier $SINGLEMDS
1090 #define OBD_FAIL_LDLM_REPLY              0x30c
1091     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1092     fail $SINGLEMDS || return 2
1093     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1094
1095     $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1096 }
1097 run_test 52 "time out lock replay (3764)"
1098
1099 # bug 3462 - simultaneous MDC requests
1100 test_53a() {
1101         cancel_lru_locks mdc    # cleanup locks from former test cases
1102         mkdir -p $DIR/${tdir}-1
1103         mkdir -p $DIR/${tdir}-2
1104         multiop $DIR/${tdir}-1/f O_c &
1105         close_pid=$!
1106         # give multiop a change to open
1107         sleep 1
1108
1109         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1110         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1111         kill -USR1 $close_pid
1112         cancel_lru_locks mdc    # force the close
1113         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1114
1115         mcreate $DIR/${tdir}-2/f || return 1
1116
1117         # close should still be here
1118         [ -d /proc/$close_pid ] || return 2
1119
1120         replay_barrier_nodf $SINGLEMDS
1121         fail $SINGLEMDS
1122         wait $close_pid || return 3
1123
1124         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1125         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1126         rm -rf $DIR/${tdir}-*
1127 }
1128 run_test 53a "|X| close request while two MDC requests in flight"
1129
1130 test_53b() {
1131         cancel_lru_locks mdc    # cleanup locks from former test cases
1132         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1133
1134         mkdir -p $DIR/${tdir}-1
1135         mkdir -p $DIR/${tdir}-2
1136         multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1137         close_pid=$!
1138
1139         #define OBD_FAIL_MDS_REINT_NET 0x107
1140         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1141         mcreate $DIR/${tdir}-2/f &
1142         open_pid=$!
1143         sleep 1
1144
1145         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1146         kill -USR1 $close_pid
1147         cancel_lru_locks mdc    # force the close
1148         wait $close_pid || return 1
1149         # open should still be here
1150         [ -d /proc/$open_pid ] || return 2
1151
1152         replay_barrier_nodf $SINGLEMDS
1153         fail $SINGLEMDS
1154         wait $open_pid || return 3
1155
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}-*
1159 }
1160 run_test 53b "|X| open request while two MDC requests in flight"
1161
1162 test_53c() {
1163         cancel_lru_locks mdc    # cleanup locks from former test cases
1164         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1165
1166         mkdir -p $DIR/${tdir}-1
1167         mkdir -p $DIR/${tdir}-2
1168         multiop $DIR/${tdir}-1/f O_c &
1169         close_pid=$!
1170
1171         #define OBD_FAIL_MDS_REINT_NET 0x107
1172         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1173         mcreate $DIR/${tdir}-2/f &
1174         open_pid=$!
1175         sleep 1
1176
1177         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1178         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1179         kill -USR1 $close_pid
1180         cancel_lru_locks mdc    # force the close
1181
1182         #bz20647: make sure all pids are exists before failover
1183         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1184         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1185         replay_barrier_nodf $SINGLEMDS
1186         fail_nodf $SINGLEMDS
1187         wait $open_pid || return 1
1188         sleep 2
1189         # close should be gone
1190         [ -d /proc/$close_pid ] && return 2
1191         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1192
1193         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1194         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1195         rm -rf $DIR/${tdir}-*
1196 }
1197 run_test 53c "|X| open request and close request while two MDC requests in flight"
1198
1199 test_53d() {
1200         cancel_lru_locks mdc    # cleanup locks from former test cases
1201         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1202
1203         mkdir -p $DIR/${tdir}-1
1204         mkdir -p $DIR/${tdir}-2
1205         multiop $DIR/${tdir}-1/f O_c &
1206         close_pid=$!
1207         # give multiop a chance to open
1208         sleep 1
1209
1210         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1211         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1212         kill -USR1 $close_pid
1213         cancel_lru_locks mdc    # force the close
1214         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1215         mcreate $DIR/${tdir}-2/f || return 1
1216
1217         # close should still be here
1218         [ -d /proc/$close_pid ] || return 2
1219         fail $SINGLEMDS
1220         wait $close_pid || return 3
1221
1222         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1223         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1224         rm -rf $DIR/${tdir}-*
1225 }
1226 run_test 53d "|X| close reply while two MDC requests in flight"
1227
1228 test_53e() {
1229         cancel_lru_locks mdc    # cleanup locks from former test cases
1230         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1231
1232         mkdir -p $DIR/${tdir}-1
1233         mkdir -p $DIR/${tdir}-2
1234         multiop $DIR/${tdir}-1/f O_c &
1235         close_pid=$!
1236
1237         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1238         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1239         mcreate $DIR/${tdir}-2/f &
1240         open_pid=$!
1241         sleep 1
1242
1243         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1244         kill -USR1 $close_pid
1245         cancel_lru_locks mdc    # force the close
1246         wait $close_pid || return 1
1247         # open should still be here
1248         [ -d /proc/$open_pid ] || return 2
1249
1250         replay_barrier_nodf $SINGLEMDS
1251         fail $SINGLEMDS
1252         wait $open_pid || return 3
1253
1254         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1255         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1256         rm -rf $DIR/${tdir}-*
1257 }
1258 run_test 53e "|X| open reply while two MDC requests in flight"
1259
1260 test_53f() {
1261         cancel_lru_locks mdc    # cleanup locks from former test cases
1262         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1263
1264         mkdir -p $DIR/${tdir}-1
1265         mkdir -p $DIR/${tdir}-2
1266         multiop $DIR/${tdir}-1/f O_c &
1267         close_pid=$!
1268
1269         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1270         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1271         mcreate $DIR/${tdir}-2/f &
1272         open_pid=$!
1273         sleep 1
1274
1275         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1276         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1277         kill -USR1 $close_pid
1278         cancel_lru_locks mdc    # force the close
1279
1280         #bz20647: make sure all pids are exists before failover
1281         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1282         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1283         replay_barrier_nodf $SINGLEMDS
1284         fail_nodf $SINGLEMDS
1285         wait $open_pid || return 1
1286         sleep 2
1287         # close should be gone
1288         [ -d /proc/$close_pid ] && return 2
1289         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1290
1291         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1292         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1293         rm -rf $DIR/${tdir}-*
1294 }
1295 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1296
1297 test_53g() {
1298         cancel_lru_locks mdc    # cleanup locks from former test cases
1299         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1300
1301         mkdir -p $DIR/${tdir}-1
1302         mkdir -p $DIR/${tdir}-2
1303         multiop $DIR/${tdir}-1/f O_c &
1304         close_pid=$!
1305
1306         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1307         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1308         mcreate $DIR/${tdir}-2/f &
1309         open_pid=$!
1310         sleep 1
1311
1312         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1313         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1314         kill -USR1 $close_pid
1315         cancel_lru_locks mdc    # force the close
1316         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1317
1318         #bz20647: make sure all pids are exists before failover
1319         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1320         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1321         replay_barrier_nodf $SINGLEMDS
1322         fail_nodf $SINGLEMDS
1323         wait $open_pid || return 1
1324         sleep 2
1325         # close should be gone
1326         [ -d /proc/$close_pid ] && return 2
1327
1328         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1329         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1330         rm -rf $DIR/${tdir}-*
1331 }
1332 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1333
1334 test_53h() {
1335         cancel_lru_locks mdc    # cleanup locks from former test cases
1336         rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1337
1338         mkdir -p $DIR/${tdir}-1
1339         mkdir -p $DIR/${tdir}-2
1340         multiop $DIR/${tdir}-1/f O_c &
1341         close_pid=$!
1342
1343         #define OBD_FAIL_MDS_REINT_NET 0x107
1344         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1345         mcreate $DIR/${tdir}-2/f &
1346         open_pid=$!
1347         sleep 1
1348
1349         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1350         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1351         kill -USR1 $close_pid
1352         cancel_lru_locks mdc    # force the close
1353         sleep 1
1354
1355         #bz20647: make sure all pids are exists before failover
1356         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1357         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1358         replay_barrier_nodf $SINGLEMDS
1359         fail_nodf $SINGLEMDS
1360         wait $open_pid || return 1
1361         sleep 2
1362         # close should be gone
1363         [ -d /proc/$close_pid ] && return 2
1364         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1365
1366         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1367         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1368         rm -rf $DIR/${tdir}-*
1369 }
1370 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1371
1372 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1373
1374 #b3761 ASSERTION(hash != 0) failed
1375 test_55() {
1376 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1377     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1378     touch $DIR/$tfile &
1379     # give touch a chance to run
1380     sleep 5
1381     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1382     rm $DIR/$tfile
1383     return 0
1384 }
1385 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1386
1387 #b3440 ASSERTION(rec->ur_fid2->id) failed
1388 test_56() {
1389     ln -s foo $DIR/$tfile
1390     replay_barrier $SINGLEMDS
1391     #drop_reply "cat $DIR/$tfile"
1392     fail $SINGLEMDS
1393     sleep 10
1394 }
1395 run_test 56 "don't replay a symlink open request (3440)"
1396
1397 #recovery one mds-ost setattr from llog
1398 test_57() {
1399 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1400     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1401     touch $DIR/$tfile
1402     replay_barrier $SINGLEMDS
1403     fail $SINGLEMDS
1404     sleep 1
1405     $CHECKSTAT -t file $DIR/$tfile || return 1
1406     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1407     rm $DIR/$tfile
1408 }
1409 run_test 57 "test recovery from llog for setattr op"
1410
1411 #recovery many mds-ost setattr from llog
1412 test_58a() {
1413     mkdir -p $DIR/$tdir
1414 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1415     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1416     createmany -o $DIR/$tdir/$tfile-%d 2500
1417     replay_barrier $SINGLEMDS
1418     fail $SINGLEMDS
1419     sleep 2
1420     $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1421     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1422     unlinkmany $DIR/$tdir/$tfile-%d 2500
1423     rmdir $DIR/$tdir
1424 }
1425 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1426
1427 test_58b() {
1428     mount_client $MOUNT2
1429     mkdir -p $DIR/$tdir
1430     touch $DIR/$tdir/$tfile
1431     replay_barrier $SINGLEMDS
1432     setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1433     fail $SINGLEMDS
1434     VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1435     [ x$VAL = x"bar" ] || return 1
1436     rm -f $DIR/$tdir/$tfile
1437     rmdir $DIR/$tdir
1438     zconf_umount `hostname` $MOUNT2
1439 }
1440 run_test 58b "test replay of setxattr op"
1441
1442 test_58c() { # bug 16570
1443         mount_client $MOUNT2
1444         mkdir -p $DIR/$tdir
1445         touch $DIR/$tdir/$tfile
1446         drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1447                 return 1
1448         VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1449         [ x$VAL = x"bar" ] || return 2
1450         drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1451                 return 3
1452         VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1453         [ x$VAL = x"bar1" ] || return 4
1454         rm -f $DIR/$tdir/$tfile
1455         rmdir $DIR/$tdir
1456         zconf_umount `hostname` $MOUNT2
1457 }
1458 run_test 58c "resend/reconstruct setxattr op"
1459
1460 # log_commit_thread vs filter_destroy race used to lead to import use after free
1461 # bug 11658
1462 test_59() {
1463     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1464
1465     mkdir -p $DIR/$tdir
1466     createmany -o $DIR/$tdir/$tfile-%d 200
1467     sync
1468     unlinkmany $DIR/$tdir/$tfile-%d 200
1469 #define OBD_FAIL_PTLRPC_DELAY_RECOV       0x507
1470     do_facet ost1 "lctl set_param fail_loc=0x507"
1471     fail ost1
1472     fail $SINGLEMDS
1473     do_facet ost1 "lctl set_param fail_loc=0x0"
1474     sleep 20
1475     rmdir $DIR/$tdir
1476 }
1477 run_test 59 "test log_commit_thread vs filter_destroy race"
1478
1479 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1480 # bug 12086: should no oops and No ctxt error for this test
1481 test_60() {
1482     mkdir -p $DIR/$tdir
1483     createmany -o $DIR/$tdir/$tfile-%d 200
1484     replay_barrier $SINGLEMDS
1485     unlinkmany $DIR/$tdir/$tfile-%d 0 100
1486     fail $SINGLEMDS
1487     unlinkmany $DIR/$tdir/$tfile-%d 100 100
1488     local no_ctxt=`dmesg | grep "No ctxt"`
1489     [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1490 }
1491 run_test 60 "test llog post recovery init vs llog unlink"
1492
1493 #test race  llog recovery thread vs llog cleanup
1494 test_61a() {    # was test_61
1495     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1496
1497     mkdir -p $DIR/$tdir
1498     createmany -o $DIR/$tdir/$tfile-%d 800
1499     replay_barrier ost1
1500 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1501     unlinkmany $DIR/$tdir/$tfile-%d 800
1502     set_nodes_failloc "$(osts_nodes)" 0x80000221
1503     facet_failover ost1
1504     sleep 10
1505     fail ost1
1506     sleep 30
1507     set_nodes_failloc "$(osts_nodes)" 0x0
1508
1509     $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1510     rmdir $DIR/$tdir
1511 }
1512 run_test 61a "test race llog recovery vs llog cleanup"
1513
1514 #test race  mds llog sync vs llog cleanup
1515 test_61b() {
1516 #   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1517     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1518     facet_failover $SINGLEMDS
1519     sleep 10
1520     fail $SINGLEMDS
1521     do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1522 }
1523 run_test 61b "test race mds llog sync vs llog cleanup"
1524
1525 #test race  cancel cookie cb vs llog cleanup
1526 test_61c() {
1527     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1528
1529 #   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1530     touch $DIR/$tfile
1531     set_nodes_failloc "$(osts_nodes)" 0x80000222
1532     rm $DIR/$tfile
1533     sleep 10
1534     fail ost1
1535     set_nodes_failloc "$(osts_nodes)" 0x0
1536 }
1537 run_test 61c "test race mds llog sync vs llog cleanup"
1538
1539 test_61d() { # bug 16002 # bug 17466 # bug 22137
1540 #   OBD_FAIL_OBD_LLOG_SETUP        0x605
1541     stop mgs
1542     do_facet mgs "lctl set_param fail_loc=0x80000605"
1543     start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1544     do_facet mgs "lctl set_param fail_loc=0"
1545     start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1546 }
1547 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1548
1549 test_62() { # Bug 15756 - don't mis-drop resent replay
1550     mkdir -p $DIR/$tdir
1551     replay_barrier $SINGLEMDS
1552     createmany -o $DIR/$tdir/$tfile- 25
1553 #define OBD_FAIL_TGT_REPLAY_DROP         0x707
1554     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1555     fail $SINGLEMDS
1556     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1557     unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1558     return 0
1559 }
1560 run_test 62 "don't mis-drop resent replay"
1561
1562 #Adaptive Timeouts (bug 3055)
1563 AT_MAX_SET=0
1564
1565 at_cleanup () {
1566     local var
1567     local facet
1568     local at_new
1569
1570     echo "Cleaning up AT ..."
1571     if [ -n "$ATOLDBASE" ]; then
1572         local at_history=$($LCTL get_param -n at_history)
1573         do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1574         do_facet ost1 "lctl set_param at_history=$at_history" || true
1575     fi
1576
1577     if [ $AT_MAX_SET -ne 0 ]; then
1578         for facet in mds client ost; do
1579             var=AT_MAX_SAVE_${facet}
1580             echo restore AT on $facet to saved value ${!var}
1581             at_max_set ${!var} $facet
1582             at_new=$(at_max_get $facet)
1583             echo Restored AT value on $facet $at_new
1584             [ $at_new -eq ${!var} ] || \
1585             error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1586         done
1587     fi
1588 }
1589
1590 at_start()
1591 {
1592     local at_max_new=600
1593
1594     # Save at_max original values
1595     local facet
1596     if [ $AT_MAX_SET -eq 0 ]; then
1597         # Suppose that all osts have the same at_max
1598         for facet in mds client ost; do
1599             eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1600         done
1601     fi
1602     local at_max
1603     for facet in mds client ost; do
1604         at_max=$(at_max_get $facet)
1605         if [ $at_max -ne $at_max_new ]; then
1606             echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1607             at_max_set $at_max_new $facet
1608             AT_MAX_SET=1
1609         fi
1610     done
1611
1612     if [ -z "$ATOLDBASE" ]; then
1613         ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1614         # speed up the timebase so we can check decreasing AT
1615         do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1616         do_facet ost1 "lctl set_param at_history=8" || true
1617
1618         # sleep for a while to cool down, should be > 8s and also allow
1619         # at least one ping to be sent. simply use TIMEOUT to be safe.
1620         sleep $TIMEOUT
1621     fi
1622 }
1623
1624 test_65a() #bug 3055
1625 {
1626     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1627
1628     at_start || return 0
1629     $LCTL dk > /dev/null
1630     debugsave
1631     sysctl -w lnet.debug="+other"
1632     # Slow down a request to the current service time, this is critical
1633     # because previous tests may have caused this value to increase.
1634     REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1635                awk '/portal 12/ {print $5}'`
1636     REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1637
1638     do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1639 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1640     do_facet $SINGLEMDS sysctl -w lustre.fail_loc=0x8000050a
1641     createmany -o $DIR/$tfile 10 > /dev/null
1642     unlinkmany $DIR/$tfile 10 > /dev/null
1643     # check for log message
1644     $LCTL dk | grep "Early reply #" || error "No early reply"
1645     debugrestore
1646     # client should show REQ_DELAY estimates
1647     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1648     sleep 9
1649     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1650 }
1651 run_test 65a "AT: verify early replies"
1652
1653 test_65b() #bug 3055
1654 {
1655     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1656
1657     at_start || return 0
1658     # turn on D_ADAPTTO
1659     debugsave
1660     sysctl -w lnet.debug="other trace"
1661     $LCTL dk > /dev/null
1662     # Slow down a request to the current service time, this is critical
1663     # because previous tests may have caused this value to increase.
1664     lfs setstripe $DIR/$tfile --index=0 --count=1
1665     multiop $DIR/$tfile Ow1yc
1666     REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1667                awk '/portal 6/ {print $5}'`
1668     REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1669
1670     do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1671 #define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
1672     do_facet ost1 sysctl -w lustre.fail_loc=0x224
1673
1674     rm -f $DIR/$tfile
1675     lfs setstripe $DIR/$tfile --index=0 --count=1
1676     # force some real bulk transfer
1677     multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1678
1679     do_facet ost1 sysctl -w lustre.fail_loc=0
1680     # check for log message
1681     $LCTL dk | grep "Early reply #" || error "No early reply"
1682     debugrestore
1683     # client should show REQ_DELAY estimates
1684     lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1685 }
1686 run_test 65b "AT: verify early replies on packed reply / bulk"
1687
1688 test_66a() #bug 3055
1689 {
1690     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1691
1692     at_start || return 0
1693     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1694     # adjust 5s at a time so no early reply is sent (within deadline)
1695     do_facet $SINGLEMDS "sysctl -w lustre.fail_val=5000"
1696 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1697     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1698     createmany -o $DIR/$tfile 20 > /dev/null
1699     unlinkmany $DIR/$tfile 20 > /dev/null
1700     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1701     do_facet $SINGLEMDS "sysctl -w lustre.fail_val=10000"
1702     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1703     createmany -o $DIR/$tfile 20 > /dev/null
1704     unlinkmany $DIR/$tfile 20 > /dev/null
1705     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1706     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1707     sleep 9
1708     createmany -o $DIR/$tfile 20 > /dev/null
1709     unlinkmany $DIR/$tfile 20 > /dev/null
1710     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1711     CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1712     WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1713     echo "Current MDT timeout $CUR, worst $WORST"
1714     [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1715 }
1716 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1717
1718 test_66b() #bug 3055
1719 {
1720     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1721
1722     at_start || return 0
1723     ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1724     sysctl -w lustre.fail_val=$(($ORIG + 5))
1725 #define OBD_FAIL_PTLRPC_PAUSE_REP      0x50c
1726     sysctl -w lustre.fail_loc=0x50c
1727     ls $DIR/$tfile > /dev/null 2>&1
1728     sysctl -w lustre.fail_loc=0
1729     CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1730     WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1731     echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1732     [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1733 }
1734 run_test 66b "AT: verify net latency adjusts"
1735
1736 test_67a() #bug 3055
1737 {
1738     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1739
1740     at_start || return 0
1741     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1742     # sleeping threads may drive values above this
1743     do_facet ost1 "sysctl -w lustre.fail_val=400"
1744 #define OBD_FAIL_PTLRPC_PAUSE_REQ    0x50a
1745     do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1746     createmany -o $DIR/$tfile 20 > /dev/null
1747     unlinkmany $DIR/$tfile 20 > /dev/null
1748     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1749     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1750     ATTEMPTS=$(($CONN2 - $CONN1))
1751     echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1752     [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1753     return 0
1754 }
1755 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1756
1757 test_67b() #bug 3055
1758 {
1759     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1760
1761     at_start || return 0
1762     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1763
1764     # exhaust precreations on ost1
1765     local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1766     local mdtosc=$(get_mdtosc_proc_path mds $OST)
1767     local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1768         osc.$mdtosc.prealloc_last_id)
1769     local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1770         osc.$mdtosc.prealloc_next_id)
1771
1772     mkdir -p $DIR/$tdir/${OST}
1773     lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1774     echo "Creating to objid $last_id on ost $OST..."
1775 #define OBD_FAIL_OST_PAUSE_CREATE        0x223
1776     do_facet ost1 "sysctl -w lustre.fail_val=20000"
1777     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1778     createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1779
1780     client_reconnect
1781     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1782     log "phase 2"
1783     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1784     ATTEMPTS=$(($CONN2 - $CONN1))
1785     echo "$ATTEMPTS osc reconnect attempts on instant slow"
1786     # do it again; should not timeout
1787     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1788     cp /etc/profile $DIR/$tfile || error "cp failed"
1789     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1790     client_reconnect
1791     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1792     CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1793     ATTEMPTS=$(($CONN3 - $CONN2))
1794     echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1795     [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1796     return 0
1797 }
1798 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1799
1800 test_68 () #bug 13813
1801 {
1802     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1803
1804     at_start || return 0
1805     local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1806     [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1807     local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1808     [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1809     local ENQ_MIN=$(cat $ldlm_enqueue_min)
1810     local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1811     echo $TIMEOUT >> $ldlm_enqueue_min
1812     do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1813
1814     rm -rf $DIR/$tdir
1815     mkdir -p $DIR/$tdir
1816     lfs setstripe $DIR/$tdir --index=0 --count=1
1817 #define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
1818     sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1819     sysctl -w lustre.fail_loc=0x80000312
1820     cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1821     sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1822     sysctl -w lustre.fail_loc=0x80000312
1823     cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1824     sysctl -w lustre.fail_loc=0
1825
1826     echo $ENQ_MIN >> $ldlm_enqueue_min
1827     do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1828     rm -rf $DIR/$tdir
1829     return 0
1830 }
1831 run_test 68 "AT: verify slowing locks"
1832
1833 at_cleanup
1834 # end of AT tests includes above lines
1835
1836
1837 # start multi-client tests
1838 test_70a () {
1839         [ -z "$CLIENTS" ] && \
1840                 { skip "Need two or more clients." && return; }
1841         [ $CLIENTCOUNT -lt 2 ] && \
1842                 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1843
1844         echo "mount clients $CLIENTS ..."
1845         zconf_mount_clients $CLIENTS $DIR
1846
1847         local clients=${CLIENTS//,/ }
1848         echo "Write/read files on $DIR ; clients $CLIENTS ... "
1849         for CLIENT in $clients; do
1850                 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1851                         of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1852                                 error "dd failed on $CLIENT"
1853         done
1854
1855         local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1856         for C in ${CLIENTS//,/ }; do
1857                 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1858                         error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1859                 prev_client=$C
1860         done
1861         
1862         ls $DIR
1863 }
1864 run_test 70a "check multi client t-f"
1865
1866 check_dbench_load () {
1867         local clients=${1//,/ }
1868         local client=
1869
1870         for client in $clients; do
1871                 if ! do_node $client "ps ax | grep -v grep | awk '{ print $6 }' | grep -q rundbench"; then
1872                         error_noexit "rundbench load on $client failed!"
1873                         return 1
1874                 fi
1875         done
1876         return 0
1877 }
1878
1879 kill_dbench_load () {
1880         local clients=${1:-$(hostname)}
1881         do_nodes $clients "killall dbench"
1882 }
1883
1884 test_70b () {
1885         local clients=${CLIENTS:-$HOSTNAME}
1886
1887         zconf_mount_clients $clients $DIR
1888         
1889         local duration=300
1890         [ "$SLOW" = "no" ] && duration=60
1891         local cmd="rundbench 1 -t $duration"
1892         local PID=""
1893         do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1894                 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1895                 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1896                 LCTL=$LCTL $cmd" &
1897         PID=$!
1898         log "Started rundbench load PID=$PID ..."
1899         ELAPSED=0
1900         NUM_FAILOVERS=0
1901         START_TS=$(date +%s)
1902         CURRENT_TS=$START_TS
1903         while [ $ELAPSED -lt $duration ]; do
1904                 if ! check_dbench_load $clients; then
1905                         kill_dbench_load $clients
1906                         break
1907                 fi
1908                 sleep 1
1909                 replay_barrier $SINGLEMDS
1910                 sleep 1 # give clients a time to do operations
1911                 # Increment the number of failovers
1912                 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1913                 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1914                 fail $SINGLEMDS
1915                 CURRENT_TS=$(date +%s)
1916                 ELAPSED=$((CURRENT_TS - START_TS))
1917         done
1918         wait $PID || error "rundbench load on $CLIENTS failed!"
1919 }
1920 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1921 # end multi-client tests
1922
1923 test_73a() {
1924     multiop_bg_pause $DIR/$tfile O_tSc || return 3
1925     pid=$!
1926     rm -f $DIR/$tfile
1927
1928     replay_barrier $SINGLEMDS
1929 #define OBD_FAIL_LDLM_ENQUEUE       0x302
1930     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1931     fail $SINGLEMDS
1932     kill -USR1 $pid
1933     wait $pid || return 1
1934     [ -e $DIR/$tfile ] && return 2
1935     return 0
1936 }
1937 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1938
1939 test_73b() {
1940     multiop_bg_pause $DIR/$tfile O_tSc || return 3
1941     pid=$!
1942     rm -f $DIR/$tfile
1943
1944     replay_barrier $SINGLEMDS
1945 #define OBD_FAIL_LDLM_REPLY       0x30c
1946     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1947     fail $SINGLEMDS
1948     kill -USR1 $pid
1949     wait $pid || return 1
1950     [ -e $DIR/$tfile ] && return 2
1951     return 0
1952 }
1953 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1954
1955 test_73c() {
1956     multiop_bg_pause $DIR/$tfile O_tSc || return 3
1957     pid=$!
1958     rm -f $DIR/$tfile
1959
1960     replay_barrier $SINGLEMDS
1961 #define OBD_FAIL_TGT_LAST_REPLAY       0x710
1962     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1963     fail $SINGLEMDS
1964     kill -USR1 $pid
1965     wait $pid || return 1
1966     [ -e $DIR/$tfile ] && return 2
1967     return 0
1968 }
1969 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1970
1971 # bug 18554
1972 test_74() {
1973     local clients=${CLIENTS:-$HOSTNAME}
1974
1975     stop ost1
1976     zconf_umount_clients $clients $MOUNT
1977     facet_failover $SINGLEMDS
1978     zconf_mount_clients $clients $MOUNT
1979     mount_facet ost1
1980     touch $DIR/$tfile || return 1
1981     rm $DIR/$tfile || return 2
1982     clients_up || error "client evicted: $?"
1983     return 0
1984 }
1985 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1986
1987 test_80a() {
1988     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1989
1990     mkdir -p $DIR/$tdir
1991     replay_barrier mds2
1992     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1993     rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1994     fail mds2
1995     stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1996     return 0
1997 }
1998 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1999
2000 test_80b() {
2001     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2002
2003     mkdir -p $DIR/$tdir
2004     replay_barrier $SINGLEMDS
2005     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
2006     rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
2007     fail $SINGLEMDS
2008     stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
2009     return 0
2010 }
2011 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
2012
2013 test_81a() {
2014     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2015
2016     mkdir -p $DIR/$tdir
2017     createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
2018     sleep 10
2019     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
2020     $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
2021     replay_barrier $SINGLEMDS
2022     rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
2023     fail $SINGLEMDS
2024     stat $DIR/$tdir/f1002
2025 }
2026 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
2027
2028 test_82a() {
2029     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2030
2031     local dir=$DIR/d82a
2032     replay_barrier mds2
2033     mkdir $dir || error "mkdir $dir failed"
2034     log "FAILOVER mds2"
2035     fail mds2
2036     stat $DIR
2037     $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2038 }
2039 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
2040
2041 test_82b() {
2042     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2043
2044     local dir=$DIR/d82b
2045     replay_barrier $SINGLEMDS
2046     mkdir $dir || error "mkdir $dir failed"
2047     log "FAILOVER mds1"
2048     fail $SINGLEMDS
2049     stat $DIR
2050     $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2051 }
2052 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2053
2054 test_83a() {
2055     mkdir -p $DIR/$tdir
2056     createmany -o $DIR/$tdir/$tfile- 10 || return 1
2057 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD       0x140
2058     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2059     unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2060 }
2061 run_test 83a "fail log_add during unlink recovery"
2062
2063 test_83b() {
2064     mkdir -p $DIR/$tdir
2065     createmany -o $DIR/$tdir/$tfile- 10 || return 1
2066     replay_barrier $SINGLEMDS
2067     unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2068 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD       0x140
2069     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2070     fail $SINGLEMDS
2071 }
2072 run_test 83b "fail log_add during unlink recovery"
2073
2074 test_84a() {
2075 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE  0x144
2076     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2077     createmany -o $DIR/$tfile- 1 &
2078     PID=$!
2079     mds_evict_client
2080     wait $PID
2081     client_up || client_up || true    # reconnect
2082 }
2083 run_test 84a "stale open during export disconnect"
2084
2085 test_85a() { #bug 16774
2086     lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2087
2088     for i in `seq 100`; do
2089         echo "tag-$i" > $DIR/$tfile-$i
2090         grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2091     done
2092
2093     lov_id=`lctl dl | grep "clilov"`
2094     addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2095     count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2096     echo "before recovery: unused locks count = $count"
2097
2098     fail $SINGLEMDS
2099
2100     count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2101     echo "after recovery: unused locks count = $count2"
2102
2103     if [ $count2 -ge $count ]; then
2104         error "unused locks are not canceled"
2105     fi
2106 }
2107 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2108
2109 test_85b() { #bug 16774
2110     lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2111
2112     lfs setstripe -o 0 -c 1 $DIR
2113
2114     for i in `seq 100`; do
2115         dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2116     done
2117
2118     cancel_lru_locks osc
2119
2120     for i in `seq 100`; do
2121         dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2122     done
2123
2124     lov_id=`lctl dl | grep "clilov"`
2125     addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2126     count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2127     echo "before recovery: unused locks count = $count"
2128
2129     fail ost1
2130
2131     count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2132     echo "after recovery: unused locks count = $count2"
2133
2134     if [ $count2 -ge $count ]; then
2135         error "unused locks are not canceled"
2136     fi
2137 }
2138 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2139
2140 test_86() {
2141         local clients=${CLIENTS:-$HOSTNAME}
2142
2143         zconf_umount_clients $clients $MOUNT
2144         do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2145         remount_facet $SINGLEMDS
2146         zconf_mount_clients $clients $MOUNT
2147 }
2148 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2149
2150 test_87() {
2151     do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2152
2153     replay_barrier ost1
2154     lfs setstripe -i 0 -c 1 $DIR/$tfile
2155     dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2156     cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2157     cancel_lru_locks osc
2158     fail ost1
2159     dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2160     cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2161     if [ $cksum != $cksum2 ] ; then
2162         error "New checksum $cksum2 does not match original $cksum"
2163     fi
2164 }
2165 run_test 87 "write replay"
2166
2167 test_87b() {
2168     do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2169
2170     replay_barrier ost1
2171     lfs setstripe -i 0 -c 1 $DIR/$tfile
2172     dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2173     sleep 1 # Give it a chance to flush dirty data
2174     echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2175     cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2176     cancel_lru_locks osc
2177     fail ost1
2178     dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2179     cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2180     if [ $cksum != $cksum2 ] ; then
2181         error "New checksum $cksum2 does not match original $cksum"
2182     fi
2183 }
2184 run_test 87b "write replay with changed data (checksum resend)"
2185
2186 test_88() { #bug 17485
2187     mkdir -p $DIR/$tdir
2188     mkdir -p $TMP/$tdir
2189
2190     lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe"
2191
2192     replay_barrier ost1
2193     replay_barrier $SINGLEMDS
2194
2195     # exhaust precreations on ost1
2196     local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
2197     local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2198     local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2199     local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2200     echo "before test: last_id = $last_id, next_id = $next_id"
2201
2202     echo "Creating to objid $last_id on ost $OST..."
2203     createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2204
2205     #create some files to use some uncommitted objids
2206     last_id=$(($last_id + 1))
2207     createmany -o $DIR/$tdir/f-%d $last_id 8
2208
2209     last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2210     next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2211     echo "before recovery: last_id = $last_id2, next_id = $next_id2" 
2212
2213     shutdown_facet $SINGLEMDS
2214     shutdown_facet ost1
2215
2216     reboot_facet $SINGLEMDS
2217     change_active $SINGLEMDS
2218     wait_for_facet $SINGLEMDS
2219     mount_facet $SINGLEMDS || error "Restart of mds failed"
2220
2221     reboot_facet ost1
2222     change_active ost1
2223     wait_for_facet ost1
2224     mount_facet ost1 || error "Restart of ost1 failed"
2225
2226     clients_up
2227
2228     last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2229     next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2230     echo "after recovery: last_id = $last_id2, next_id = $next_id2" 
2231
2232     # create new files, which should use new objids, and ensure the orphan 
2233     # cleanup phase for ost1 is completed at the same time
2234     for i in `seq 8`; do
2235         file_id=$(($last_id + 10 + $i))
2236         dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2237     done
2238
2239     # if the objids were not recreated, then "ls" will failed for -ENOENT
2240     ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2241
2242     local file_id
2243     # write into previously created files
2244     for i in `seq 8`; do
2245         file_id=$(($last_id + $i))
2246         dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2247         cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2248     done
2249
2250     # compare the content
2251     for i in `seq 8`; do
2252         file_id=$(($last_id + $i))
2253         cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2254         "of file is modified!"
2255     done
2256
2257     rm -fr $TMP/$tdir
2258 }
2259 run_test 88 "MDS should not assign same objid to different files "
2260
2261 test_89() {
2262         cancel_lru_locks osc
2263         mkdir -p $DIR/$tdir
2264         rm -f $DIR/$tdir/$tfile
2265         wait_mds_ost_sync
2266         wait_destroy_complete
2267         BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2268         lfs setstripe -i 0 -c 1 $DIR/$tdir/$tfile
2269         dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2270         sync
2271         stop ost1
2272         facet_failover $SINGLEMDS
2273         rm $DIR/$tdir/$tfile
2274         umount $MOUNT
2275         mount_facet ost1
2276         zconf_mount $(hostname) $MOUNT
2277         client_up || return 1
2278         wait_mds_ost_sync
2279         BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2280         [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2281 }
2282
2283 run_test 89 "no disk space leak on late ost connection"
2284
2285 equals_msg `basename $0`: test complete, cleaning up
2286 check_and_cleanup_lustre
2287 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true