Whamcloud - gitweb
b=14901
[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:-`dirname $0`/..}
11 SETUP=${SETUP:-}
12 CLEANUP=${CLEANUP:-}
13 . $LUSTRE/tests/test-framework.sh
14 init_test_env $@
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
18
19
20 # Skip these tests
21 # bug number: 2766 4176   11404
22 ALWAYS_EXCEPT="0b  39     56    $REPLAY_SINGLE_EXCEPT"
23
24 #                                                     63 min  7 min  AT AT AT AT"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 6b 12 16 44      44b    65 66 67 68"
26
27 build_test_filter
28
29 cleanup_and_setup_lustre
30
31 mkdir -p $DIR
32
33 rm -rf $DIR/[df][0-9]*
34
35 test_0() {
36     sleep 10
37     mkdir $DIR/$tfile
38     replay_barrier $SINGLEMDS
39     fail $SINGLEMDS
40     rmdir $DIR/$tfile
41 }
42 run_test 0 "empty replay"
43
44 test_0b() {
45     # this test attempts to trigger a race in the precreation code,
46     # and must run before any other objects are created on the filesystem
47     fail ost1
48     createmany -o $DIR/$tfile 20 || return 1
49     unlinkmany $DIR/$tfile 20 || return 2
50 }
51 run_test 0b "ensure object created after recover exists. (3284)"
52
53 seq_set_width()
54 {
55     local mds=$1
56     local width=$2
57     local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
58     echo $width > $file
59 }
60
61 seq_get_width()
62 {
63     local mds=$1
64     local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
65     cat $file
66 }
67
68 # This test should pass for single-mds and multi-mds configs.
69 # But for different configurations it tests different things.
70 #
71 # single-mds
72 # ----------
73 # (1) fld_create replay should happen;
74 #
75 # (2) fld_create replay should not return -EEXISTS, if it does
76 # this means sequence manager recovery code is buggy and allocated
77 # same sequence two times after recovery.
78 #
79 # multi-mds
80 # ---------
81 # (1) fld_create replay may not happen, because its home MDS is
82 # MDS2 which is not involved to revovery;
83 #
84 # (2) as fld_create does not happen on MDS1, it does not make any
85 # problem.
86 test_0c() {
87     local label=`mdsdevlabel 1`
88     [ -z "$label" ] && echo "No label for mds1" && return 1
89
90     replay_barrier $SINGLEMDS
91     local sw=`seq_get_width $label`
92
93     # make seq manager switch to next sequence each
94     # time as new fid is needed.
95     seq_set_width $label 1
96
97     # make sure that fld has created at least one new
98     # entry on server
99     touch $DIR/$tfile || return 2
100     seq_set_width $label $sw
101
102     # fail $SINGLEMDS and start recovery, replay RPCs, etc.
103     fail $SINGLEMDS
104
105     # wait for recovery finish
106     sleep 10
107     df $MOUNT
108
109     # flush fld cache and dentry cache to make it lookup
110     # created entry instead of revalidating existent one
111     umount $MOUNT
112     zconf_mount `hostname` $MOUNT
113
114     # issue lookup which should call fld lookup which
115     # should fail if client did not replay fld create
116     # correctly and server has no fld entry
117     touch $DIR/$tfile || return 3
118     rm $DIR/$tfile || return 4
119 }
120 run_test 0c "fld create"
121
122 test_1() {
123     replay_barrier $SINGLEMDS
124     mcreate $DIR/$tfile
125     fail $SINGLEMDS
126     $CHECKSTAT -t file $DIR/$tfile || return 1
127     rm $DIR/$tfile
128 }
129 run_test 1 "simple create"
130
131 test_2a() {
132     replay_barrier $SINGLEMDS
133     touch $DIR/$tfile
134     fail $SINGLEMDS
135     $CHECKSTAT -t file $DIR/$tfile || return 1
136     rm $DIR/$tfile
137 }
138 run_test 2a "touch"
139
140 test_2b() {
141     mcreate $DIR/$tfile
142     replay_barrier $SINGLEMDS
143     touch $DIR/$tfile
144     fail $SINGLEMDS
145     $CHECKSTAT -t file $DIR/$tfile || return 1
146     rm $DIR/$tfile
147 }
148 run_test 2b "touch"
149
150 test_3a() {
151     replay_barrier $SINGLEMDS
152     mcreate $DIR/$tfile
153     o_directory $DIR/$tfile
154     fail $SINGLEMDS
155     $CHECKSTAT -t file $DIR/$tfile || return 2
156     rm $DIR/$tfile
157 }
158 run_test 3a "replay failed open(O_DIRECTORY)"
159
160 test_3b() {
161     replay_barrier $SINGLEMDS
162 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
163     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000114"
164     touch $DIR/$tfile
165     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
166     fail $SINGLEMDS
167     $CHECKSTAT -t file $DIR/$tfile && return 2
168     return 0
169 }
170 run_test 3b "replay failed open -ENOMEM"
171
172 test_3c() {
173     replay_barrier $SINGLEMDS
174 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
175     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000128"
176     touch $DIR/$tfile
177     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
178     fail $SINGLEMDS
179
180     $CHECKSTAT -t file $DIR/$tfile && return 2
181     return 0
182 }
183 run_test 3c "replay failed open -ENOMEM"
184
185 test_4() {
186     replay_barrier $SINGLEMDS
187     for i in `seq 10`; do
188         echo "tag-$i" > $DIR/$tfile-$i
189     done
190     fail $SINGLEMDS
191     for i in `seq 10`; do
192       grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
193     done
194 }
195 run_test 4 "|x| 10 open(O_CREAT)s"
196
197 test_4b() {
198     replay_barrier $SINGLEMDS
199     rm -rf $DIR/$tfile-*
200     fail $SINGLEMDS
201     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
202 }
203 run_test 4b "|x| rm 10 files"
204
205 # The idea is to get past the first block of precreated files on both
206 # osts, and then replay.
207 test_5() {
208     replay_barrier $SINGLEMDS
209     for i in `seq 220`; do
210         echo "tag-$i" > $DIR/$tfile-$i
211     done
212     fail $SINGLEMDS
213     for i in `seq 220`; do
214       grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
215     done
216     rm -rf $DIR/$tfile-*
217     sleep 3
218     # waiting for commitment of removal
219 }
220 run_test 5 "|x| 220 open(O_CREAT)"
221
222
223 test_6() {
224     replay_barrier $SINGLEMDS
225     mcreate $DIR/$tdir/$tfile
226     fail $SINGLEMDS
227     $CHECKSTAT -t dir $DIR/$tdir || return 1
228     $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
229     sleep 2
230     # waiting for log process thread
231 }
232 run_test 6 "mkdir + contained create"
233
234 test_6b() {
235     replay_barrier $SINGLEMDS
236     rm -rf $DIR/$tdir
237     fail $SINGLEMDS
238     $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
239 }
240 run_test 6b "|X| rmdir"
241
242 test_7() {
243     replay_barrier $SINGLEMDS
244     mcreate $DIR/$tdir/$tfile
245     fail $SINGLEMDS
246     $CHECKSTAT -t dir $DIR/$tdir || return 1
247     $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
248     rm -fr $DIR/$tdir
249 }
250 run_test 7 "mkdir |X| contained create"
251
252 test_8() {
253     # make sure no side-effect from previous test.
254     rm -f $DIR/$tfile
255     replay_barrier $SINGLEMDS
256     multiop_bg_pause $DIR/$tfile mo_c || return 4
257     MULTIPID=$!
258     fail $SINGLEMDS
259     ls $DIR/$tfile
260     $CHECKSTAT -t file $DIR/$tfile || return 1
261     kill -USR1 $MULTIPID || return 2
262     wait $MULTIPID || return 3
263     rm $DIR/$tfile
264 }
265 run_test 8 "creat open |X| close"
266
267 test_9() {
268     replay_barrier $SINGLEMDS
269     mcreate $DIR/$tfile
270     local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
271     fail $SINGLEMDS
272     local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
273
274     echo " old_inum == $old_inum, new_inum == $new_inum"
275     if [ $old_inum -eq $new_inum  ] ;
276     then
277         echo " old_inum and new_inum match"
278     else
279         echo "!!!! old_inum and new_inum NOT match"
280         return 1
281     fi
282     rm $DIR/$tfile
283 }
284 run_test 9  "|X| create (same inum/gen)"
285
286 test_10() {
287     mcreate $DIR/$tfile
288     replay_barrier $SINGLEMDS
289     mv $DIR/$tfile $DIR/$tfile-2
290     rm -f $DIR/$tfile
291     fail $SINGLEMDS
292     $CHECKSTAT $DIR/$tfile && return 1
293     $CHECKSTAT $DIR/$tfile-2 ||return 2
294     rm $DIR/$tfile-2
295     return 0
296 }
297 run_test 10 "create |X| rename unlink"
298
299 test_11() {
300     mcreate $DIR/$tfile
301     echo "old" > $DIR/$tfile
302     mv $DIR/$tfile $DIR/$tfile-2
303     replay_barrier $SINGLEMDS
304     echo "new" > $DIR/$tfile
305     grep new $DIR/$tfile
306     grep old $DIR/$tfile-2
307     fail $SINGLEMDS
308     grep new $DIR/$tfile || return 1
309     grep old $DIR/$tfile-2 || return 2
310 }
311 run_test 11 "create open write rename |X| create-old-name read"
312
313 test_12() {
314     mcreate $DIR/$tfile
315     multiop_bg_pause $DIR/$tfile o_tSc || return 3
316     pid=$!
317     rm -f $DIR/$tfile
318     replay_barrier $SINGLEMDS
319     kill -USR1 $pid
320     wait $pid || return 1
321
322     fail $SINGLEMDS
323     [ -e $DIR/$tfile ] && return 2
324     return 0
325 }
326 run_test 12 "open, unlink |X| close"
327
328
329 # 1777 - replay open after committed chmod that would make
330 #        a regular open a failure
331 test_13() {
332     mcreate $DIR/$tfile
333     multiop_bg_pause $DIR/$tfile O_wc || return 3
334     pid=$!
335     chmod 0 $DIR/$tfile
336     $CHECKSTAT -p 0 $DIR/$tfile
337     replay_barrier $SINGLEMDS
338     fail $SINGLEMDS
339     kill -USR1 $pid
340     wait $pid || return 1
341
342     $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
343     return 0
344 }
345 run_test 13 "open chmod 0 |x| write close"
346
347 test_14() {
348     multiop_bg_pause $DIR/$tfile O_tSc || return 4
349     pid=$!
350     rm -f $DIR/$tfile
351     replay_barrier $SINGLEMDS
352     kill -USR1 $pid || return 1
353     wait $pid || return 2
354
355     fail $SINGLEMDS
356     [ -e $DIR/$tfile ] && return 3
357     return 0
358 }
359 run_test 14 "open(O_CREAT), unlink |X| close"
360
361 test_15() {
362     multiop_bg_pause $DIR/$tfile O_tSc || return 5
363     pid=$!
364     rm -f $DIR/$tfile
365     replay_barrier $SINGLEMDS
366     touch $DIR/g11 || return 1
367     kill -USR1 $pid
368     wait $pid || return 2
369
370     fail $SINGLEMDS
371     [ -e $DIR/$tfile ] && return 3
372     touch $DIR/h11 || return 4
373     return 0
374 }
375 run_test 15 "open(O_CREAT), unlink |X|  touch new, close"
376
377
378 test_16() {
379     replay_barrier $SINGLEMDS
380     mcreate $DIR/$tfile
381     munlink $DIR/$tfile
382     mcreate $DIR/$tfile-2
383     fail $SINGLEMDS
384     [ -e $DIR/$tfile ] && return 1
385     [ -e $DIR/$tfile-2 ] || return 2
386     munlink $DIR/$tfile-2 || return 3
387 }
388 run_test 16 "|X| open(O_CREAT), unlink, touch new,  unlink new"
389
390 test_17() {
391     replay_barrier $SINGLEMDS
392     multiop_bg_pause $DIR/$tfile O_c || return 4
393     pid=$!
394     fail $SINGLEMDS
395     kill -USR1 $pid || return 1
396     wait $pid || return 2
397     $CHECKSTAT -t file $DIR/$tfile || return 3
398     rm $DIR/$tfile
399 }
400 run_test 17 "|X| open(O_CREAT), |replay| close"
401
402 test_18() {
403     replay_barrier $SINGLEMDS
404     multiop_bg_pause $DIR/$tfile O_tSc || return 8
405     pid=$!
406     rm -f $DIR/$tfile
407     touch $DIR/$tfile-2 || return 1
408     echo "pid: $pid will close"
409     kill -USR1 $pid
410     wait $pid || return 2
411
412     fail $SINGLEMDS
413     [ -e $DIR/$tfile ] && return 3
414     [ -e $DIR/$tfile-2 ] || return 4
415     # this touch frequently fails
416     touch $DIR/$tfile-3 || return 5
417     munlink $DIR/$tfile-2 || return 6
418     munlink $DIR/$tfile-3 || return 7
419     return 0
420 }
421 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
422
423 # bug 1855 (a simpler form of test_11 above)
424 test_19() {
425     replay_barrier $SINGLEMDS
426     mcreate $DIR/$tfile
427     echo "old" > $DIR/$tfile
428     mv $DIR/$tfile $DIR/$tfile-2
429     grep old $DIR/$tfile-2
430     fail $SINGLEMDS
431     grep old $DIR/$tfile-2 || return 2
432 }
433 run_test 19 "|X| mcreate, open, write, rename "
434
435 test_20() {
436     replay_barrier $SINGLEMDS
437     multiop_bg_pause $DIR/$tfile O_tSc || return 3
438     pid=$!
439     rm -f $DIR/$tfile
440
441     fail $SINGLEMDS
442     kill -USR1 $pid
443     wait $pid || return 1
444     [ -e $DIR/$tfile ] && return 2
445     return 0
446 }
447 run_test 20 "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
448
449 test_20b() { # bug 10480
450     BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
451
452     dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
453     pid=$!
454     while [ ! -e $DIR/$tfile ] ; do
455         usleep 60                           # give dd a chance to start
456     done
457
458     lfs getstripe $DIR/$tfile || return 1
459     rm -f $DIR/$tfile || return 2       # make it an orphan
460     mds_evict_client
461     df -P $DIR || df -P $DIR || true    # reconnect
462
463     fail $SINGLEMDS                            # start orphan recovery
464     df -P $DIR || df -P $DIR || true    # reconnect
465     wait_mds_recovery_done || error "MDS recovery not done"
466
467     # FIXME just because recovery is done doesn't mean we've finished
468     # orphan cleanup.  Fake it with a sleep for now...
469     sleep 10
470     AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
471     log "before $BEFOREUSED, after $AFTERUSED"
472     [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
473         error "after $AFTERUSED > before $BEFOREUSED"
474     return 0
475 }
476 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
477
478 test_20c() { # bug 10480
479     multiop_bg_pause $DIR/$tfile Ow_c || return 1
480     pid=$!
481
482     ls -la $DIR/$tfile
483
484     mds_evict_client
485
486     df -P $DIR || df -P $DIR || true    # reconnect
487
488     kill -USR1 $pid
489     test -s $DIR/$tfile || error "File was truncated"
490
491     return 0
492 }
493 run_test 20c "check that client eviction does not affect file content"
494
495 test_21() {
496     replay_barrier $SINGLEMDS
497     multiop_bg_pause $DIR/$tfile O_tSc || return 5
498     pid=$!
499     rm -f $DIR/$tfile
500     touch $DIR/g11 || return 1
501
502     fail $SINGLEMDS
503     kill -USR1 $pid
504     wait $pid || return 2
505     [ -e $DIR/$tfile ] && return 3
506     touch $DIR/h11 || return 4
507     return 0
508 }
509 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
510
511 test_22() {
512     multiop_bg_pause $DIR/$tfile O_tSc || return 3
513     pid=$!
514
515     replay_barrier $SINGLEMDS
516     rm -f $DIR/$tfile
517
518     fail $SINGLEMDS
519     kill -USR1 $pid
520     wait $pid || return 1
521     [ -e $DIR/$tfile ] && return 2
522     return 0
523 }
524 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
525
526 test_23() {
527     multiop_bg_pause $DIR/$tfile O_tSc || return 5
528     pid=$!
529
530     replay_barrier $SINGLEMDS
531     rm -f $DIR/$tfile
532     touch $DIR/g11 || return 1
533
534     fail $SINGLEMDS
535     kill -USR1 $pid
536     wait $pid || return 2
537     [ -e $DIR/$tfile ] && return 3
538     touch $DIR/h11 || return 4
539     return 0
540 }
541 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
542
543 test_24() {
544     multiop_bg_pause $DIR/$tfile O_tSc || return 3
545     pid=$!
546
547     replay_barrier $SINGLEMDS
548     fail $SINGLEMDS
549     rm -f $DIR/$tfile
550     kill -USR1 $pid
551     wait $pid || return 1
552     [ -e $DIR/$tfile ] && return 2
553     return 0
554 }
555 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
556
557 test_25() {
558     multiop_bg_pause $DIR/$tfile O_tSc || return 3
559     pid=$!
560     rm -f $DIR/$tfile
561
562     replay_barrier $SINGLEMDS
563     fail $SINGLEMDS
564     kill -USR1 $pid
565     wait $pid || return 1
566     [ -e $DIR/$tfile ] && return 2
567     return 0
568 }
569 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
570
571 test_26() {
572     replay_barrier $SINGLEMDS
573     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
574     pid1=$!
575     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
576     pid2=$!
577     rm -f $DIR/$tfile-1
578     rm -f $DIR/$tfile-2
579     kill -USR1 $pid2
580     wait $pid2 || return 1
581
582     fail $SINGLEMDS
583     kill -USR1 $pid1
584     wait $pid1 || return 2
585     [ -e $DIR/$tfile-1 ] && return 3
586     [ -e $DIR/$tfile-2 ] && return 4
587     return 0
588 }
589 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
590
591 test_27() {
592     replay_barrier $SINGLEMDS
593     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
594     pid1=$!
595     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
596     pid2=$!
597     rm -f $DIR/$tfile-1
598     rm -f $DIR/$tfile-2
599
600     fail $SINGLEMDS
601     kill -USR1 $pid1
602     wait $pid1 || return 1
603     kill -USR1 $pid2
604     wait $pid2 || return 2
605     [ -e $DIR/$tfile-1 ] && return 3
606     [ -e $DIR/$tfile-2 ] && return 4
607     return 0
608 }
609 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
610
611 test_28() {
612     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
613     pid1=$!
614     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
615     pid2=$!
616     replay_barrier $SINGLEMDS
617     rm -f $DIR/$tfile-1
618     rm -f $DIR/$tfile-2
619     kill -USR1 $pid2
620     wait $pid2 || return 1
621
622     fail $SINGLEMDS
623     kill -USR1 $pid1
624     wait $pid1 || return 2
625     [ -e $DIR/$tfile-1 ] && return 3
626     [ -e $DIR/$tfile-2 ] && return 4
627     return 0
628 }
629 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
630
631 test_29() {
632     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
633     pid1=$!
634     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
635     pid2=$!
636     replay_barrier $SINGLEMDS
637     rm -f $DIR/$tfile-1
638     rm -f $DIR/$tfile-2
639
640     fail $SINGLEMDS
641     kill -USR1 $pid1
642     wait $pid1 || return 1
643     kill -USR1 $pid2
644     wait $pid2 || return 2
645     [ -e $DIR/$tfile-1 ] && return 3
646     [ -e $DIR/$tfile-2 ] && return 4
647     return 0
648 }
649 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
650
651 test_30() {
652     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
653     pid1=$!
654     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
655     pid2=$!
656     rm -f $DIR/$tfile-1
657     rm -f $DIR/$tfile-2
658
659     replay_barrier $SINGLEMDS
660     fail $SINGLEMDS
661     kill -USR1 $pid1
662     wait $pid1 || return 1
663     kill -USR1 $pid2
664     wait $pid2 || return 2
665     [ -e $DIR/$tfile-1 ] && return 3
666     [ -e $DIR/$tfile-2 ] && return 4
667     return 0
668 }
669 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
670
671 test_31() {
672     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
673     pid1=$!
674     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
675     pid2=$!
676     rm -f $DIR/$tfile-1
677
678     replay_barrier $SINGLEMDS
679     rm -f $DIR/$tfile-2
680     fail $SINGLEMDS
681     kill -USR1 $pid1
682     wait $pid1 || return 1
683     kill -USR1 $pid2
684     wait $pid2 || return 2
685     [ -e $DIR/$tfile-1 ] && return 3
686     [ -e $DIR/$tfile-2 ] && return 4
687     return 0
688 }
689 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
690
691 # tests for bug 2104; completion without crashing is success.  The close is
692 # stale, but we always return 0 for close, so the app never sees it.
693 test_32() {
694     multiop_bg_pause $DIR/$tfile O_c || return 2
695     pid1=$!
696     multiop_bg_pause $DIR/$tfile O_c || return 3
697     pid2=$!
698     mds_evict_client
699     df $MOUNT || sleep 1 && df $MOUNT || return 1
700     kill -USR1 $pid1
701     kill -USR1 $pid2
702     sleep 1
703     return 0
704 }
705 run_test 32 "close() notices client eviction; close() after client eviction"
706
707 # Abort recovery before client complete
708 test_33() {
709     replay_barrier $SINGLEMDS
710     createmany -o $DIR/$tfile-%d 100
711     fail_abort $SINGLEMDS
712     # this file should be gone, because the replay was aborted
713     $CHECKSTAT -t file $DIR/$tfile-* && return 3
714     unlinkmany $DIR/$tfile-%d 0 100
715     return 0
716 }
717 run_test 33 "abort recovery before client does replay"
718
719 # Stale FID sequence
720 test_33a() {
721     replay_barrier $SINGLEMDS
722     createmany -o $DIR/$tfile-%d 10
723     fail_abort $SINGLEMDS
724     unlinkmany $DIR/$tfile-%d 0 10
725     # recreate shouldn't fail
726     createmany -o $DIR/$tfile-%d 10 || return 3
727     unlinkmany $DIR/$tfile-%d 0 10
728     return 0
729 }
730 run_test 33a "fid shouldn't be reused after abort recovery"
731
732 test_34() {
733     multiop_bg_pause $DIR/$tfile O_c || return 2
734     pid=$!
735     rm -f $DIR/$tfile
736
737     replay_barrier $SINGLEMDS
738     fail_abort $SINGLEMDS
739     kill -USR1 $pid
740     [ -e $DIR/$tfile ] && return 1
741     sync
742     return 0
743 }
744 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
745
746 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
747 test_35() {
748     touch $DIR/$tfile
749
750 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
751     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
752     rm -f $DIR/$tfile &
753     sleep 1
754     sync
755     sleep 1
756     # give a chance to remove from MDS
757     fail_abort $SINGLEMDS
758     $CHECKSTAT -t file $DIR/$tfile && return 1 || true
759 }
760 run_test 35 "test recovery from llog for unlink op"
761
762 # b=2432 resent cancel after replay uses wrong cookie,
763 # so don't resend cancels
764 test_36() {
765     replay_barrier $SINGLEMDS
766     touch $DIR/$tfile
767     checkstat $DIR/$tfile
768     facet_failover $SINGLEMDS
769     cancel_lru_locks mdc
770     if dmesg | grep "unknown lock cookie"; then
771         echo "cancel after replay failed"
772         return 1
773     fi
774 }
775 run_test 36 "don't resend cancel"
776
777 # b=2368
778 # directory orphans can't be unlinked from PENDING directory
779 test_37() {
780     rmdir $DIR/$tfile 2>/dev/null
781     multiop_bg_pause $DIR/$tfile dD_c || return 2
782     pid=$!
783     rmdir $DIR/$tfile
784
785     replay_barrier $SINGLEMDS
786     # clear the dmesg buffer so we only see errors from this recovery
787     dmesg -c >/dev/null
788     fail_abort $SINGLEMDS
789     kill -USR1 $pid
790     dmesg | grep  "mds_unlink_orphan.*error .* unlinking orphan" && return 1
791     sync
792     return 0
793 }
794 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
795
796 test_38() {
797     createmany -o $DIR/$tfile-%d 800
798     unlinkmany $DIR/$tfile-%d 0 400
799     replay_barrier $SINGLEMDS
800     fail $SINGLEMDS
801     unlinkmany $DIR/$tfile-%d 400 400
802     sleep 2
803     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
804 }
805 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
806
807 test_39() { # bug 4176
808     createmany -o $DIR/$tfile-%d 800
809     replay_barrier $SINGLEMDS
810     unlinkmany $DIR/$tfile-%d 0 400
811     fail $SINGLEMDS
812     unlinkmany $DIR/$tfile-%d 400 400
813     sleep 2
814     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
815 }
816 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
817
818 count_ost_writes() {
819     awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }' $LPROC/osc/*/stats
820 }
821
822 #b=2477,2532
823 test_40(){
824     $LCTL mark multiop $MOUNT/$tfile OS_c
825     multiop $MOUNT/$tfile OS_c  &
826     PID=$!
827     writeme -s $MOUNT/${tfile}-2 &
828     WRITE_PID=$!
829     sleep 1
830     facet_failover $SINGLEMDS
831 #define OBD_FAIL_MDS_CONNECT_NET         0x117
832     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000117"
833     kill -USR1 $PID
834     stat1=`count_ost_writes`
835     sleep $TIMEOUT
836     stat2=`count_ost_writes`
837     echo "$stat1, $stat2"
838     if [ $stat1 -lt $stat2 ]; then
839        echo "writes continuing during recovery"
840        RC=0
841     else
842        echo "writes not continuing during recovery, bug 2477"
843        RC=4
844     fi
845     echo "waiting for writeme $WRITE_PID"
846     kill $WRITE_PID
847     wait $WRITE_PID
848
849     echo "waiting for multiop $PID"
850     wait $PID || return 2
851     do_facet client munlink $MOUNT/$tfile  || return 3
852     do_facet client munlink $MOUNT/${tfile}-2  || return 3
853     return $RC
854 }
855 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
856
857
858 #b=2814
859 # make sure that a read to one osc doesn't try to double-unlock its page just
860 # because another osc is invalid.  trigger_group_io used to mistakenly return
861 # an error if any oscs were invalid even after having successfully put rpcs
862 # on valid oscs.  This was fatal if the caller was ll_readpage who unlocked
863 # the page, guarnateeing that the unlock from the RPC completion would
864 # assert on trying to unlock the unlocked page.
865 test_41() {
866     [ $OSTCOUNT -lt 2 ] && \
867         skip "skipping test 41: we don't have a second OST to test with" && \
868         return
869
870     local f=$MOUNT/$tfile
871     # make sure the start of the file is ost1
872     lfs setstripe $f -s $((128 * 1024)) -i 0
873     do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
874     cancel_lru_locks osc
875     # fail ost2 and read from ost1
876     local osc2dev=`do_facet mds "grep ${ost2_svc}-osc-MDT0000 $LPROC/devices" | awk '{print $1}'`
877     [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && cat $LPROC/devices && return 4
878     do_facet mds $LCTL --device $osc2dev deactivate || return 1
879     do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
880     do_facet mds $LCTL --device $osc2dev activate || return 2
881     return 0
882 }
883 run_test 41 "read from a valid osc while other oscs are invalid"
884
885 # test MDS recovery after ost failure
886 test_42() {
887     blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
888     createmany -o $DIR/$tfile-%d 800
889     replay_barrier ost1
890     unlinkmany $DIR/$tfile-%d 0 400
891     debugsave
892     sysctl -w lnet.debug=-1
893     facet_failover ost1
894
895     # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
896     #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
897     #[ $blocks_after -lt $blocks ] || return 1
898     echo wait for MDS to timeout and recover
899     sleep $((TIMEOUT * 2))
900     debugrestore
901     unlinkmany $DIR/$tfile-%d 400 400
902     $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
903 }
904 run_test 42 "recovery after ost failure"
905
906 # timeout in MDS/OST recovery RPC will LBUG MDS
907 test_43() { # bug 2530
908     replay_barrier $SINGLEMDS
909
910     # OBD_FAIL_OST_CREATE_NET 0x204
911     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
912     fail $SINGLEMDS
913     sleep 10
914     do_facet ost1 "sysctl -w lustre.fail_loc=0"
915
916     return 0
917 }
918 run_test 43 "mds osc import failure during recovery; don't LBUG"
919
920 test_44() {
921     mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
922     [ "$mdcdev" ] || exit 2
923     for i in `seq 1 10`; do
924         #define OBD_FAIL_TGT_CONN_RACE     0x701
925         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000701"
926         $LCTL --device $mdcdev recover
927         df $MOUNT
928     done
929     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
930     return 0
931 }
932 run_test 44 "race in target handle connect"
933
934 test_44b() {
935     mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
936     [ "$mdcdev" ] || exit 2
937     for i in `seq 1 10`; do
938         #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
939         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000704"
940         $LCTL --device $mdcdev recover
941         df $MOUNT
942     done
943     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
944     return 0
945 }
946 run_test 44b "race in target handle connect"
947
948 # Handle failed close
949 test_45() {
950     mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
951     [ "$mdcdev" ] || exit 2
952     $LCTL --device $mdcdev recover
953
954     multiop_bg_pause $DIR/$tfile O_c || return 1
955     pid=$!
956
957     # This will cause the CLOSE to fail before even
958     # allocating a reply buffer
959     $LCTL --device $mdcdev deactivate || return 4
960
961     # try the close
962     kill -USR1 $pid
963     wait $pid || return 1
964
965     $LCTL --device $mdcdev activate || return 5
966     sleep 1
967
968     $CHECKSTAT -t file $DIR/$tfile || return 2
969     return 0
970 }
971 run_test 45 "Handle failed close"
972
973 test_46() {
974     dmesg -c >/dev/null
975     drop_reply "touch $DIR/$tfile"
976     fail $SINGLEMDS
977     # ironically, the previous test, 45, will cause a real forced close,
978     # so just look for one for this test
979     dmesg | grep -i "force closing client file handle for $tfile" && return 1
980     return 0
981 }
982 run_test 46 "Don't leak file handle after open resend (3325)"
983
984 test_47() { # bug 2824
985     # create some files to make sure precreate has been done on all
986     # OSTs. (just in case this test is run independently)
987     createmany -o $DIR/$tfile 20  || return 1
988
989     # OBD_FAIL_OST_CREATE_NET 0x204
990     fail ost1
991     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
992     df $MOUNT || return 2
993
994     # let the MDS discover the OST failure, attempt to recover, fail
995     # and recover again.
996     sleep $((3 * TIMEOUT))
997
998     # Without 2824, this createmany would hang
999     createmany -o $DIR/$tfile 20 || return 3
1000     unlinkmany $DIR/$tfile 20 || return 4
1001
1002     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1003     return 0
1004 }
1005 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1006
1007 test_48() {
1008     replay_barrier $SINGLEMDS
1009     createmany -o $DIR/$tfile 20  || return 1
1010     # OBD_FAIL_OST_EROFS 0x216
1011     fail $SINGLEMDS
1012     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000216"
1013     df $MOUNT || return 2
1014
1015     createmany -o $DIR/$tfile 20 20 || return 2
1016     unlinkmany $DIR/$tfile 40 || return 3
1017
1018     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1019     return 0
1020 }
1021 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1022
1023 test_50() {
1024     local oscdev=`do_facet $SINGLEMDS grep ${ost1_svc}-osc-MDT0000 $LPROC/devices | awk '{print $1}'`
1025     [ "$oscdev" ] || return 1
1026     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1027     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1028     # give the mds_lov_sync threads a chance to run
1029     sleep 5
1030 }
1031 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1032
1033 # b3764 timed out lock replay
1034 test_52() {
1035     touch $DIR/$tfile
1036     cancel_lru_locks mdc
1037
1038     multiop $DIR/$tfile s || return 1
1039     replay_barrier $SINGLEMDS
1040 #define OBD_FAIL_LDLM_REPLY              0x30c
1041     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000030c"
1042     fail $SINGLEMDS || return 2
1043     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1044
1045     $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1046 }
1047 run_test 52 "time out lock replay (3764)"
1048
1049 # bug 3462 - simultaneous MDC requests
1050 test_53a() {
1051         mkdir -p $DIR/${tdir}-1
1052         mkdir -p $DIR/${tdir}-2
1053         multiop $DIR/${tdir}-1/f O_c &
1054         close_pid=$!
1055         # give multiop a change to open
1056         sleep 1
1057
1058         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1059         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1060         kill -USR1 $close_pid
1061         cancel_lru_locks mdc    # force the close
1062         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1063
1064         mcreate $DIR/${tdir}-2/f || return 1
1065
1066         # close should still be here
1067         [ -d /proc/$close_pid ] || return 2
1068
1069         replay_barrier_nodf $SINGLEMDS
1070         fail $SINGLEMDS
1071         wait $close_pid || return 3
1072
1073         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1074         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1075         rm -rf $DIR/${tdir}-*
1076 }
1077 run_test 53a "|X| close request while two MDC requests in flight"
1078
1079 test_53b() {
1080         mkdir -p $DIR/${tdir}-1
1081         mkdir -p $DIR/${tdir}-2
1082         multiop $DIR/${tdir}-1/f O_c &
1083         close_pid=$!
1084
1085         #define OBD_FAIL_MDS_REINT_NET 0x107
1086         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1087         mcreate $DIR/${tdir}-2/f &
1088         open_pid=$!
1089         sleep 1
1090
1091         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1092         kill -USR1 $close_pid
1093         cancel_lru_locks mdc    # force the close
1094         wait $close_pid || return 1
1095         # open should still be here
1096         [ -d /proc/$open_pid ] || return 2
1097
1098         replay_barrier_nodf $SINGLEMDS
1099         fail $SINGLEMDS
1100         wait $open_pid || return 3
1101
1102         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1103         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1104         rm -rf $DIR/${tdir}-*
1105 }
1106 run_test 53b "|X| open request while two MDC requests in flight"
1107
1108 test_53c() {
1109         mkdir -p $DIR/${tdir}-1
1110         mkdir -p $DIR/${tdir}-2
1111         multiop $DIR/${tdir}-1/f O_c &
1112         close_pid=$!
1113
1114         #define OBD_FAIL_MDS_REINT_NET 0x107
1115         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1116         mcreate $DIR/${tdir}-2/f &
1117         open_pid=$!
1118         sleep 1
1119
1120         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1121         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1122         kill -USR1 $close_pid
1123         cancel_lru_locks mdc    # force the close
1124
1125         replay_barrier_nodf $SINGLEMDS
1126         fail_nodf $SINGLEMDS
1127         wait $open_pid || return 1
1128         sleep 2
1129         # close should be gone
1130         [ -d /proc/$close_pid ] && return 2
1131         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1132
1133         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1134         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1135         rm -rf $DIR/${tdir}-*
1136 }
1137 run_test 53c "|X| open request and close request while two MDC requests in flight"
1138
1139 test_53d() {
1140         mkdir -p $DIR/${tdir}-1
1141         mkdir -p $DIR/${tdir}-2
1142         multiop $DIR/${tdir}-1/f O_c &
1143         close_pid=$!
1144         # give multiop a chance to open
1145         sleep 1
1146
1147         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1148         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1149         kill -USR1 $close_pid
1150         cancel_lru_locks mdc    # force the close
1151         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1152         mcreate $DIR/${tdir}-2/f || return 1
1153
1154         # close should still be here
1155         [ -d /proc/$close_pid ] || return 2
1156         fail $SINGLEMDS
1157         wait $close_pid || return 3
1158
1159         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1160         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1161         rm -rf $DIR/${tdir}-*
1162 }
1163 run_test 53d "|X| close reply while two MDC requests in flight"
1164
1165 test_53e() {
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_REP 0x119
1172         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1173         mcreate $DIR/${tdir}-2/f &
1174         open_pid=$!
1175         sleep 1
1176
1177         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1178         kill -USR1 $close_pid
1179         cancel_lru_locks mdc    # force the close
1180         wait $close_pid || return 1
1181         # open should still be here
1182         [ -d /proc/$open_pid ] || return 2
1183
1184         replay_barrier_nodf $SINGLEMDS
1185         fail $SINGLEMDS
1186         wait $open_pid || return 3
1187
1188         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1189         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1190         rm -rf $DIR/${tdir}-*
1191 }
1192 run_test 53e "|X| open reply while two MDC requests in flight"
1193
1194 test_53f() {
1195         mkdir -p $DIR/${tdir}-1
1196         mkdir -p $DIR/${tdir}-2
1197         multiop $DIR/${tdir}-1/f O_c &
1198         close_pid=$!
1199
1200         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1201         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1202         mcreate $DIR/${tdir}-2/f &
1203         open_pid=$!
1204         sleep 1
1205
1206         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1207         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1208         kill -USR1 $close_pid
1209         cancel_lru_locks mdc    # force the close
1210
1211         replay_barrier_nodf $SINGLEMDS
1212         fail_nodf $SINGLEMDS
1213         wait $open_pid || return 1
1214         sleep 2
1215         # close should be gone
1216         [ -d /proc/$close_pid ] && return 2
1217         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1218
1219         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1220         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1221         rm -rf $DIR/${tdir}-*
1222 }
1223 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1224
1225 test_53g() {
1226         mkdir -p $DIR/${tdir}-1
1227         mkdir -p $DIR/${tdir}-2
1228         multiop $DIR/${tdir}-1/f O_c &
1229         close_pid=$!
1230
1231         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1232         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1233         mcreate $DIR/${tdir}-2/f &
1234         open_pid=$!
1235         sleep 1
1236
1237         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1238         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1239         kill -USR1 $close_pid
1240         cancel_lru_locks mdc    # force the close
1241
1242         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1243         replay_barrier_nodf $SINGLEMDS
1244         fail_nodf $SINGLEMDS
1245         wait $open_pid || return 1
1246         sleep 2
1247         # close should be gone
1248         [ -d /proc/$close_pid ] && return 2
1249
1250         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1251         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1252         rm -rf $DIR/${tdir}-*
1253 }
1254 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1255
1256 test_53h() {
1257         mkdir -p $DIR/${tdir}-1
1258         mkdir -p $DIR/${tdir}-2
1259         multiop $DIR/${tdir}-1/f O_c &
1260         close_pid=$!
1261
1262         #define OBD_FAIL_MDS_REINT_NET 0x107
1263         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1264         mcreate $DIR/${tdir}-2/f &
1265         open_pid=$!
1266         sleep 1
1267
1268         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1269         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1270         kill -USR1 $close_pid
1271         cancel_lru_locks mdc    # force the close
1272         sleep 1
1273
1274         replay_barrier_nodf $SINGLEMDS
1275         fail_nodf $SINGLEMDS
1276         wait $open_pid || return 1
1277         sleep 2
1278         # close should be gone
1279         [ -d /proc/$close_pid ] && return 2
1280         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1281
1282         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1283         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1284         rm -rf $DIR/${tdir}-*
1285 }
1286 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1287
1288 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1289
1290 #b3761 ASSERTION(hash != 0) failed
1291 test_55() {
1292 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1293     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012b"
1294     touch $DIR/$tfile &
1295     # give touch a chance to run
1296     sleep 5
1297     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1298     rm $DIR/$tfile
1299     return 0
1300 }
1301 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1302
1303 #b3440 ASSERTION(rec->ur_fid2->id) failed
1304 test_56() {
1305     ln -s foo $DIR/$tfile
1306     replay_barrier $SINGLEMDS
1307     #drop_reply "cat $DIR/$tfile"
1308     fail $SINGLEMDS
1309     sleep 10
1310 }
1311 run_test 56 "don't replay a symlink open request (3440)"
1312
1313 #recovery one mds-ost setattr from llog
1314 test_57() {
1315 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1316     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1317     touch $DIR/$tfile
1318     replay_barrier $SINGLEMDS
1319     fail $SINGLEMDS
1320     sleep 1
1321     $CHECKSTAT -t file $DIR/$tfile || return 1
1322     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1323     rm $DIR/$tfile
1324 }
1325 run_test 57 "test recovery from llog for setattr op"
1326
1327 #recovery many mds-ost setattr from llog
1328 test_58() {
1329 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1330     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1331     createmany -o $DIR/$tdir/$tfile-%d 2500
1332     replay_barrier $SINGLEMDS
1333     fail $SINGLEMDS
1334     sleep 2
1335     $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1336     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1337     unlinkmany $DIR/$tdir/$tfile-%d 2500
1338     rmdir $DIR/$tdir
1339 }
1340 run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)"
1341
1342 # log_commit_thread vs filter_destroy race used to lead to import use after free
1343 # bug 11658
1344 test_59() {
1345     createmany -o $DIR/$tdir/$tfile-%d 200
1346     sync
1347     unlinkmany $DIR/$tdir/$tfile-%d 200
1348 #define OBD_FAIL_PTLRPC_DELAY_RECOV       0x507
1349     do_facet ost1 "sysctl -w lustre.fail_loc=0x507"
1350     fail ost1
1351     fail $SINGLEMDS
1352     do_facet ost1 "sysctl -w lustre.fail_loc=0x0"
1353     sleep 20
1354     rmdir $DIR/$tdir
1355 }
1356 run_test 59 "test log_commit_thread vs filter_destroy race"
1357
1358 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1359 # bug 12086: should no oops and No ctxt error for this test
1360 test_60() {
1361     createmany -o $DIR/$tdir/$tfile-%d 200
1362     replay_barrier $SINGLEMDS
1363     unlinkmany $DIR/$tdir/$tfile-%d 0 100
1364     fail $SINGLEMDS
1365     unlinkmany $DIR/$tdir/$tfile-%d 100 100
1366     local no_ctxt=`dmesg | grep "No ctxt"`
1367     [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1368 }
1369 run_test 60 "test llog post recovery init vs llog unlink"
1370
1371 #test race  llog recovery thread vs llog cleanup
1372 test_61() {
1373     mkdir $DIR/$tdir
1374     createmany -o $DIR/$tdir/$tfile-%d 800
1375     replay_barrier ost1 
1376 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 
1377     unlinkmany $DIR/$tdir/$tfile-%d 800 
1378     do_facet ost "sysctl -w lustre.fail_loc=0x80000221"
1379     facet_failover ost1
1380     sleep 10 
1381     fail ost1
1382     sleep 30
1383     do_facet ost "sysctl -w lustre.fail_loc=0x0"
1384     $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1385     rmdir $DIR/$tdir
1386 }
1387 run_test 61 "test race llog recovery vs llog cleanup"
1388
1389 #test race  mds llog sync vs llog cleanup
1390 test_61b() {
1391 #   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x140
1392     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000140"
1393     facet_failover $SINGLEMDS 
1394     sleep 10
1395     fail $SINGLEMDS
1396     do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1397 }
1398 run_test 61b "test race mds llog sync vs llog cleanup"
1399
1400 #test race  cancel cookie cb vs llog cleanup
1401 test_61c() {
1402 #   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222 
1403     touch $DIR/$tfile 
1404     do_facet ost "sysctl -w lustre.fail_loc=0x80000222"
1405     rm $DIR/$tfile    
1406     sleep 10
1407     fail ost1
1408 }
1409 run_test 61c "test race mds llog sync vs llog cleanup"
1410
1411 equals_msg `basename $0`: test complete, cleaning up
1412 check_and_cleanup_lustre
1413 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true