Whamcloud - gitweb
b=16727
[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 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
18
19
20 # Skip these tests
21 # bug number:
22 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
23
24 #                                                  63 min  7 min  AT AT AT AT"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a      44b    65 66 67 68"
26
27 build_test_filter
28
29 cleanup_and_setup_lustre
30
31 mkdir -p $DIR
32
33 assert_DIR
34 rm -rf $DIR/[df][0-9]*
35
36 test_0a() {     # was test_0
37     sleep 10
38     mkdir $DIR/$tfile
39     replay_barrier $SINGLEMDS
40     fail $SINGLEMDS
41     rmdir $DIR/$tfile
42 }
43 run_test 0a "empty replay"
44
45 test_0b() {
46     # this test attempts to trigger a race in the precreation code,
47     # and must run before any other objects are created on the filesystem
48     fail ost1
49     createmany -o $DIR/$tfile 20 || return 1
50     unlinkmany $DIR/$tfile 20 || return 2
51 }
52 run_test 0b "ensure object created after recover exists. (3284)"
53
54 seq_set_width()
55 {
56     local mds=$1
57     local width=$2
58     lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
59 }
60
61 seq_get_width()
62 {
63     local mds=$1
64     lctl get_param -n seq.cli-srv-$mds-mdc-*.width
65 }
66
67 # This test should pass for single-mds and multi-mds configs.
68 # But for different configurations it tests different things.
69 #
70 # single-mds
71 # ----------
72 # (1) fld_create replay should happen;
73 #
74 # (2) fld_create replay should not return -EEXISTS, if it does
75 # this means sequence manager recovery code is buggy and allocated
76 # same sequence two times after recovery.
77 #
78 # multi-mds
79 # ---------
80 # (1) fld_create replay may not happen, because its home MDS is
81 # MDS2 which is not involved to revovery;
82 #
83 # (2) as fld_create does not happen on MDS1, it does not make any
84 # problem.
85 test_0c() {
86     local label=`mdsdevlabel 1`
87     [ -z "$label" ] && echo "No label for mds1" && return 1
88
89     replay_barrier $SINGLEMDS
90     local sw=`seq_get_width $label`
91
92     # make seq manager switch to next sequence each
93     # time as new fid is needed.
94     seq_set_width $label 1
95
96     # make sure that fld has created at least one new
97     # entry on server
98     touch $DIR/$tfile || return 2
99     seq_set_width $label $sw
100
101     # fail $SINGLEMDS and start recovery, replay RPCs, etc.
102     fail $SINGLEMDS
103
104     # wait for recovery finish
105     sleep 10
106     df $MOUNT
107
108     # flush fld cache and dentry cache to make it lookup
109     # created entry instead of revalidating existent one
110     umount $MOUNT
111     zconf_mount `hostname` $MOUNT
112
113     # issue lookup which should call fld lookup which
114     # should fail if client did not replay fld create
115     # correctly and server has no fld entry
116     touch $DIR/$tfile || return 3
117     rm $DIR/$tfile || return 4
118 }
119 run_test 0c "fld create"
120
121 test_1() {
122     replay_barrier $SINGLEMDS
123     mcreate $DIR/$tfile
124     fail $SINGLEMDS
125     $CHECKSTAT -t file $DIR/$tfile || return 1
126     rm $DIR/$tfile
127 }
128 run_test 1 "simple create"
129
130 test_2a() {
131     replay_barrier $SINGLEMDS
132     touch $DIR/$tfile
133     fail $SINGLEMDS
134     $CHECKSTAT -t file $DIR/$tfile || return 1
135     rm $DIR/$tfile
136 }
137 run_test 2a "touch"
138
139 test_2b() {
140     mcreate $DIR/$tfile
141     replay_barrier $SINGLEMDS
142     touch $DIR/$tfile
143     fail $SINGLEMDS
144     $CHECKSTAT -t file $DIR/$tfile || return 1
145     rm $DIR/$tfile
146 }
147 run_test 2b "touch"
148
149 test_3a() {
150     replay_barrier $SINGLEMDS
151     mcreate $DIR/$tfile
152     o_directory $DIR/$tfile
153     fail $SINGLEMDS
154     $CHECKSTAT -t file $DIR/$tfile || return 2
155     rm $DIR/$tfile
156 }
157 run_test 3a "replay failed open(O_DIRECTORY)"
158
159 test_3b() {
160     replay_barrier $SINGLEMDS
161 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
162     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
163     touch $DIR/$tfile
164     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
165     fail $SINGLEMDS
166     $CHECKSTAT -t file $DIR/$tfile && return 2
167     return 0
168 }
169 run_test 3b "replay failed open -ENOMEM"
170
171 test_3c() {
172     replay_barrier $SINGLEMDS
173 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
174     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
175     touch $DIR/$tfile
176     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
177     fail $SINGLEMDS
178
179     $CHECKSTAT -t file $DIR/$tfile && return 2
180     return 0
181 }
182 run_test 3c "replay failed open -ENOMEM"
183
184 test_4a() {     # was test_4
185     replay_barrier $SINGLEMDS
186     for i in `seq 10`; do
187         echo "tag-$i" > $DIR/$tfile-$i
188     done
189     fail $SINGLEMDS
190     for i in `seq 10`; do
191       grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
192     done
193 }
194 run_test 4a "|x| 10 open(O_CREAT)s"
195
196 test_4b() {
197     replay_barrier $SINGLEMDS
198     rm -rf $DIR/$tfile-*
199     fail $SINGLEMDS
200     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
201 }
202 run_test 4b "|x| rm 10 files"
203
204 # The idea is to get past the first block of precreated files on both
205 # osts, and then replay.
206 test_5() {
207     replay_barrier $SINGLEMDS
208     for i in `seq 220`; do
209         echo "tag-$i" > $DIR/$tfile-$i
210     done
211     fail $SINGLEMDS
212     for i in `seq 220`; do
213       grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
214     done
215     rm -rf $DIR/$tfile-*
216     sleep 3
217     # waiting for commitment of removal
218 }
219 run_test 5 "|x| 220 open(O_CREAT)"
220
221
222 test_6a() {     # was test_6
223     mkdir -p $DIR/$tdir
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 6a "mkdir + contained create"
233
234 test_6b() {
235     mkdir -p $DIR/$tdir
236     replay_barrier $SINGLEMDS
237     rm -rf $DIR/$tdir
238     fail $SINGLEMDS
239     $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
240 }
241 run_test 6b "|X| rmdir"
242
243 test_7() {
244     mkdir -p $DIR/$tdir
245     replay_barrier $SINGLEMDS
246     mcreate $DIR/$tdir/$tfile
247     fail $SINGLEMDS
248     $CHECKSTAT -t dir $DIR/$tdir || return 1
249     $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
250     rm -fr $DIR/$tdir
251 }
252 run_test 7 "mkdir |X| contained create"
253
254 test_8() {
255     # make sure no side-effect from previous test.
256     rm -f $DIR/$tfile
257     replay_barrier $SINGLEMDS
258     multiop_bg_pause $DIR/$tfile mo_c || return 4
259     MULTIPID=$!
260     fail $SINGLEMDS
261     ls $DIR/$tfile
262     $CHECKSTAT -t file $DIR/$tfile || return 1
263     kill -USR1 $MULTIPID || return 2
264     wait $MULTIPID || return 3
265     rm $DIR/$tfile
266 }
267 run_test 8 "creat open |X| close"
268
269 test_9() {
270     replay_barrier $SINGLEMDS
271     mcreate $DIR/$tfile
272     local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
273     fail $SINGLEMDS
274     local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
275
276     echo " old_inum == $old_inum, new_inum == $new_inum"
277     if [ $old_inum -eq $new_inum  ] ;
278     then
279         echo " old_inum and new_inum match"
280     else
281         echo "!!!! old_inum and new_inum NOT match"
282         return 1
283     fi
284     rm $DIR/$tfile
285 }
286 run_test 9  "|X| create (same inum/gen)"
287
288 test_10() {
289     mcreate $DIR/$tfile
290     replay_barrier $SINGLEMDS
291     mv $DIR/$tfile $DIR/$tfile-2
292     rm -f $DIR/$tfile
293     fail $SINGLEMDS
294     $CHECKSTAT $DIR/$tfile && return 1
295     $CHECKSTAT $DIR/$tfile-2 ||return 2
296     rm $DIR/$tfile-2
297     return 0
298 }
299 run_test 10 "create |X| rename unlink"
300
301 test_11() {
302     mcreate $DIR/$tfile
303     echo "old" > $DIR/$tfile
304     mv $DIR/$tfile $DIR/$tfile-2
305     replay_barrier $SINGLEMDS
306     echo "new" > $DIR/$tfile
307     grep new $DIR/$tfile
308     grep old $DIR/$tfile-2
309     fail $SINGLEMDS
310     grep new $DIR/$tfile || return 1
311     grep old $DIR/$tfile-2 || return 2
312 }
313 run_test 11 "create open write rename |X| create-old-name read"
314
315 test_12() {
316     mcreate $DIR/$tfile
317     multiop_bg_pause $DIR/$tfile o_tSc || return 3
318     pid=$!
319     rm -f $DIR/$tfile
320     replay_barrier $SINGLEMDS
321     kill -USR1 $pid
322     wait $pid || return 1
323
324     fail $SINGLEMDS
325     [ -e $DIR/$tfile ] && return 2
326     return 0
327 }
328 run_test 12 "open, unlink |X| close"
329
330
331 # 1777 - replay open after committed chmod that would make
332 #        a regular open a failure
333 test_13() {
334     mcreate $DIR/$tfile
335     multiop_bg_pause $DIR/$tfile O_wc || return 3
336     pid=$!
337     chmod 0 $DIR/$tfile
338     $CHECKSTAT -p 0 $DIR/$tfile
339     replay_barrier $SINGLEMDS
340     fail $SINGLEMDS
341     kill -USR1 $pid
342     wait $pid || return 1
343
344     $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
345     return 0
346 }
347 run_test 13 "open chmod 0 |x| write close"
348
349 test_14() {
350     multiop_bg_pause $DIR/$tfile O_tSc || return 4
351     pid=$!
352     rm -f $DIR/$tfile
353     replay_barrier $SINGLEMDS
354     kill -USR1 $pid || return 1
355     wait $pid || return 2
356
357     fail $SINGLEMDS
358     [ -e $DIR/$tfile ] && return 3
359     return 0
360 }
361 run_test 14 "open(O_CREAT), unlink |X| close"
362
363 test_15() {
364     multiop_bg_pause $DIR/$tfile O_tSc || return 5
365     pid=$!
366     rm -f $DIR/$tfile
367     replay_barrier $SINGLEMDS
368     touch $DIR/g11 || return 1
369     kill -USR1 $pid
370     wait $pid || return 2
371
372     fail $SINGLEMDS
373     [ -e $DIR/$tfile ] && return 3
374     touch $DIR/h11 || return 4
375     return 0
376 }
377 run_test 15 "open(O_CREAT), unlink |X|  touch new, close"
378
379
380 test_16() {
381     replay_barrier $SINGLEMDS
382     mcreate $DIR/$tfile
383     munlink $DIR/$tfile
384     mcreate $DIR/$tfile-2
385     fail $SINGLEMDS
386     [ -e $DIR/$tfile ] && return 1
387     [ -e $DIR/$tfile-2 ] || return 2
388     munlink $DIR/$tfile-2 || return 3
389 }
390 run_test 16 "|X| open(O_CREAT), unlink, touch new,  unlink new"
391
392 test_17() {
393     replay_barrier $SINGLEMDS
394     multiop_bg_pause $DIR/$tfile O_c || return 4
395     pid=$!
396     fail $SINGLEMDS
397     kill -USR1 $pid || return 1
398     wait $pid || return 2
399     $CHECKSTAT -t file $DIR/$tfile || return 3
400     rm $DIR/$tfile
401 }
402 run_test 17 "|X| open(O_CREAT), |replay| close"
403
404 test_18() {
405     replay_barrier $SINGLEMDS
406     multiop_bg_pause $DIR/$tfile O_tSc || return 8
407     pid=$!
408     rm -f $DIR/$tfile
409     touch $DIR/$tfile-2 || return 1
410     echo "pid: $pid will close"
411     kill -USR1 $pid
412     wait $pid || return 2
413
414     fail $SINGLEMDS
415     [ -e $DIR/$tfile ] && return 3
416     [ -e $DIR/$tfile-2 ] || return 4
417     # this touch frequently fails
418     touch $DIR/$tfile-3 || return 5
419     munlink $DIR/$tfile-2 || return 6
420     munlink $DIR/$tfile-3 || return 7
421     return 0
422 }
423 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
424
425 # bug 1855 (a simpler form of test_11 above)
426 test_19() {
427     replay_barrier $SINGLEMDS
428     mcreate $DIR/$tfile
429     echo "old" > $DIR/$tfile
430     mv $DIR/$tfile $DIR/$tfile-2
431     grep old $DIR/$tfile-2
432     fail $SINGLEMDS
433     grep old $DIR/$tfile-2 || return 2
434 }
435 run_test 19 "|X| mcreate, open, write, rename "
436
437 test_20a() {    # was test_20
438     replay_barrier $SINGLEMDS
439     multiop_bg_pause $DIR/$tfile O_tSc || return 3
440     pid=$!
441     rm -f $DIR/$tfile
442
443     fail $SINGLEMDS
444     kill -USR1 $pid
445     wait $pid || return 1
446     [ -e $DIR/$tfile ] && return 2
447     return 0
448 }
449 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
450
451 test_20b() { # bug 10480
452     BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
453
454     dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
455     pid=$!
456     while [ ! -e $DIR/$tfile ] ; do
457         usleep 60                           # give dd a chance to start
458     done
459
460     lfs getstripe $DIR/$tfile || return 1
461     rm -f $DIR/$tfile || return 2       # make it an orphan
462     mds_evict_client
463     df -P $DIR || df -P $DIR || true    # reconnect
464
465     fail $SINGLEMDS                            # start orphan recovery
466     df -P $DIR || df -P $DIR || true    # reconnect
467     wait_mds_recovery_done || error "MDS recovery not done"
468
469     # FIXME just because recovery is done doesn't mean we've finished
470     # orphan cleanup.  Fake it with a sleep for now...
471     sleep 10
472     AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
473     log "before $BEFOREUSED, after $AFTERUSED"
474     [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
475         error "after $AFTERUSED > before $BEFOREUSED"
476     return 0
477 }
478 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
479
480 test_20c() { # bug 10480
481     multiop_bg_pause $DIR/$tfile Ow_c || return 1
482     pid=$!
483
484     ls -la $DIR/$tfile
485
486     mds_evict_client
487
488     df -P $DIR || df -P $DIR || true    # reconnect
489
490     kill -USR1 $pid
491     test -s $DIR/$tfile || error "File was truncated"
492
493     wait $pid || return 1
494     return 0
495 }
496 run_test 20c "check that client eviction does not affect file content"
497
498 test_21() {
499     replay_barrier $SINGLEMDS
500     multiop_bg_pause $DIR/$tfile O_tSc || return 5
501     pid=$!
502     rm -f $DIR/$tfile
503     touch $DIR/g11 || return 1
504
505     fail $SINGLEMDS
506     kill -USR1 $pid
507     wait $pid || return 2
508     [ -e $DIR/$tfile ] && return 3
509     touch $DIR/h11 || return 4
510     return 0
511 }
512 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
513
514 test_22() {
515     multiop_bg_pause $DIR/$tfile O_tSc || return 3
516     pid=$!
517
518     replay_barrier $SINGLEMDS
519     rm -f $DIR/$tfile
520
521     fail $SINGLEMDS
522     kill -USR1 $pid
523     wait $pid || return 1
524     [ -e $DIR/$tfile ] && return 2
525     return 0
526 }
527 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
528
529 test_23() {
530     multiop_bg_pause $DIR/$tfile O_tSc || return 5
531     pid=$!
532
533     replay_barrier $SINGLEMDS
534     rm -f $DIR/$tfile
535     touch $DIR/g11 || return 1
536
537     fail $SINGLEMDS
538     kill -USR1 $pid
539     wait $pid || return 2
540     [ -e $DIR/$tfile ] && return 3
541     touch $DIR/h11 || return 4
542     return 0
543 }
544 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
545
546 test_24() {
547     multiop_bg_pause $DIR/$tfile O_tSc || return 3
548     pid=$!
549
550     replay_barrier $SINGLEMDS
551     fail $SINGLEMDS
552     rm -f $DIR/$tfile
553     kill -USR1 $pid
554     wait $pid || return 1
555     [ -e $DIR/$tfile ] && return 2
556     return 0
557 }
558 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
559
560 test_25() {
561     multiop_bg_pause $DIR/$tfile O_tSc || return 3
562     pid=$!
563     rm -f $DIR/$tfile
564
565     replay_barrier $SINGLEMDS
566     fail $SINGLEMDS
567     kill -USR1 $pid
568     wait $pid || return 1
569     [ -e $DIR/$tfile ] && return 2
570     return 0
571 }
572 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
573
574 test_26() {
575     replay_barrier $SINGLEMDS
576     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
577     pid1=$!
578     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
579     pid2=$!
580     rm -f $DIR/$tfile-1
581     rm -f $DIR/$tfile-2
582     kill -USR1 $pid2
583     wait $pid2 || return 1
584
585     fail $SINGLEMDS
586     kill -USR1 $pid1
587     wait $pid1 || return 2
588     [ -e $DIR/$tfile-1 ] && return 3
589     [ -e $DIR/$tfile-2 ] && return 4
590     return 0
591 }
592 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
593
594 test_27() {
595     replay_barrier $SINGLEMDS
596     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
597     pid1=$!
598     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
599     pid2=$!
600     rm -f $DIR/$tfile-1
601     rm -f $DIR/$tfile-2
602
603     fail $SINGLEMDS
604     kill -USR1 $pid1
605     wait $pid1 || return 1
606     kill -USR1 $pid2
607     wait $pid2 || return 2
608     [ -e $DIR/$tfile-1 ] && return 3
609     [ -e $DIR/$tfile-2 ] && return 4
610     return 0
611 }
612 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
613
614 test_28() {
615     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
616     pid1=$!
617     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
618     pid2=$!
619     replay_barrier $SINGLEMDS
620     rm -f $DIR/$tfile-1
621     rm -f $DIR/$tfile-2
622     kill -USR1 $pid2
623     wait $pid2 || return 1
624
625     fail $SINGLEMDS
626     kill -USR1 $pid1
627     wait $pid1 || return 2
628     [ -e $DIR/$tfile-1 ] && return 3
629     [ -e $DIR/$tfile-2 ] && return 4
630     return 0
631 }
632 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
633
634 test_29() {
635     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
636     pid1=$!
637     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
638     pid2=$!
639     replay_barrier $SINGLEMDS
640     rm -f $DIR/$tfile-1
641     rm -f $DIR/$tfile-2
642
643     fail $SINGLEMDS
644     kill -USR1 $pid1
645     wait $pid1 || return 1
646     kill -USR1 $pid2
647     wait $pid2 || return 2
648     [ -e $DIR/$tfile-1 ] && return 3
649     [ -e $DIR/$tfile-2 ] && return 4
650     return 0
651 }
652 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
653
654 test_30() {
655     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
656     pid1=$!
657     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
658     pid2=$!
659     rm -f $DIR/$tfile-1
660     rm -f $DIR/$tfile-2
661
662     replay_barrier $SINGLEMDS
663     fail $SINGLEMDS
664     kill -USR1 $pid1
665     wait $pid1 || return 1
666     kill -USR1 $pid2
667     wait $pid2 || return 2
668     [ -e $DIR/$tfile-1 ] && return 3
669     [ -e $DIR/$tfile-2 ] && return 4
670     return 0
671 }
672 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
673
674 test_31() {
675     multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
676     pid1=$!
677     multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
678     pid2=$!
679     rm -f $DIR/$tfile-1
680
681     replay_barrier $SINGLEMDS
682     rm -f $DIR/$tfile-2
683     fail $SINGLEMDS
684     kill -USR1 $pid1
685     wait $pid1 || return 1
686     kill -USR1 $pid2
687     wait $pid2 || return 2
688     [ -e $DIR/$tfile-1 ] && return 3
689     [ -e $DIR/$tfile-2 ] && return 4
690     return 0
691 }
692 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
693
694 # tests for bug 2104; completion without crashing is success.  The close is
695 # stale, but we always return 0 for close, so the app never sees it.
696 test_32() {
697     multiop_bg_pause $DIR/$tfile O_c || return 2
698     pid1=$!
699     multiop_bg_pause $DIR/$tfile O_c || return 3
700     pid2=$!
701     mds_evict_client
702     df $MOUNT || sleep 1 && df $MOUNT || return 1
703     kill -USR1 $pid1
704     kill -USR1 $pid2
705     wait $pid1 || return 4
706     wait $pid2 || return 5
707     return 0
708 }
709 run_test 32 "close() notices client eviction; close() after client eviction"
710
711 # Abort recovery before client complete
712 test_33a() {    # was test_33
713     replay_barrier $SINGLEMDS
714     createmany -o $DIR/$tfile-%d 100
715     fail_abort $SINGLEMDS
716     # this file should be gone, because the replay was aborted
717     $CHECKSTAT -t file $DIR/$tfile-* && return 3
718     unlinkmany $DIR/$tfile-%d 0 100
719     return 0
720 }
721 run_test 33a "abort recovery before client does replay"
722
723 # Stale FID sequence
724 test_33b() {    # was test_33a
725     replay_barrier $SINGLEMDS
726     createmany -o $DIR/$tfile-%d 10
727     fail_abort $SINGLEMDS
728     unlinkmany $DIR/$tfile-%d 0 10
729     # recreate shouldn't fail
730     createmany -o $DIR/$tfile-%d 10 || return 3
731     unlinkmany $DIR/$tfile-%d 0 10
732     return 0
733 }
734 run_test 33b "fid shouldn't be reused after abort recovery"
735
736 test_34() {
737     multiop_bg_pause $DIR/$tfile O_c || return 2
738     pid=$!
739     rm -f $DIR/$tfile
740
741     replay_barrier $SINGLEMDS
742     fail_abort $SINGLEMDS
743     kill -USR1 $pid
744     wait $pid || return 3
745     [ -e $DIR/$tfile ] && return 1
746     sync
747     return 0
748 }
749 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
750
751 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
752 test_35() {
753     touch $DIR/$tfile
754
755 #define OBD_FAIL_MDS_REINT_NET_REP       0x119
756     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
757     rm -f $DIR/$tfile &
758     sleep 1
759     sync
760     sleep 1
761     # give a chance to remove from MDS
762     fail_abort $SINGLEMDS
763     $CHECKSTAT -t file $DIR/$tfile && return 1 || true
764 }
765 run_test 35 "test recovery from llog for unlink op"
766
767 # b=2432 resent cancel after replay uses wrong cookie,
768 # so don't resend cancels
769 test_36() {
770     replay_barrier $SINGLEMDS
771     touch $DIR/$tfile
772     checkstat $DIR/$tfile
773     facet_failover $SINGLEMDS
774     cancel_lru_locks mdc
775     if dmesg | grep "unknown lock cookie"; then
776         echo "cancel after replay failed"
777         return 1
778     fi
779 }
780 run_test 36 "don't resend cancel"
781
782 # b=2368
783 # directory orphans can't be unlinked from PENDING directory
784 test_37() {
785     rmdir $DIR/$tfile 2>/dev/null
786     multiop_bg_pause $DIR/$tfile dD_c || return 2
787     pid=$!
788     rmdir $DIR/$tfile
789
790     replay_barrier $SINGLEMDS
791     # clear the dmesg buffer so we only see errors from this recovery
792     dmesg -c >/dev/null
793     fail_abort $SINGLEMDS
794     kill -USR1 $pid
795     dmesg | grep  "mds_unlink_orphan.*error .* unlinking orphan" && return 1
796     wait $pid || return 3
797     sync
798     return 0
799 }
800 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
801
802 test_38() {
803     createmany -o $DIR/$tfile-%d 800
804     unlinkmany $DIR/$tfile-%d 0 400
805     replay_barrier $SINGLEMDS
806     fail $SINGLEMDS
807     unlinkmany $DIR/$tfile-%d 400 400
808     sleep 2
809     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
810 }
811 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
812
813 test_39() { # bug 4176
814     createmany -o $DIR/$tfile-%d 800
815     replay_barrier $SINGLEMDS
816     unlinkmany $DIR/$tfile-%d 0 400
817     fail $SINGLEMDS
818     unlinkmany $DIR/$tfile-%d 400 400
819     sleep 2
820     $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
821 }
822 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
823
824 count_ost_writes() {
825     lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
826 }
827
828 #b=2477,2532
829 test_40(){
830     $LCTL mark multiop $MOUNT/$tfile OS_c
831     multiop $MOUNT/$tfile OS_c  &
832     PID=$!
833     writeme -s $MOUNT/${tfile}-2 &
834     WRITE_PID=$!
835     sleep 1
836     facet_failover $SINGLEMDS
837 #define OBD_FAIL_MDS_CONNECT_NET         0x117
838     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
839     kill -USR1 $PID
840     stat1=`count_ost_writes`
841     sleep $TIMEOUT
842     stat2=`count_ost_writes`
843     echo "$stat1, $stat2"
844     if [ $stat1 -lt $stat2 ]; then
845        echo "writes continuing during recovery"
846        RC=0
847     else
848        echo "writes not continuing during recovery, bug 2477"
849        RC=4
850     fi
851     echo "waiting for writeme $WRITE_PID"
852     kill $WRITE_PID
853     wait $WRITE_PID
854
855     echo "waiting for multiop $PID"
856     wait $PID || return 2
857     do_facet client munlink $MOUNT/$tfile  || return 3
858     do_facet client munlink $MOUNT/${tfile}-2  || return 3
859     return $RC
860 }
861 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
862
863
864 #b=2814
865 # make sure that a read to one osc doesn't try to double-unlock its page just
866 # because another osc is invalid.  trigger_group_io used to mistakenly return
867 # an error if any oscs were invalid even after having successfully put rpcs
868 # on valid oscs.  This was fatal if the caller was ll_readpage who unlocked
869 # the page, guarnateeing that the unlock from the RPC completion would
870 # assert on trying to unlock the unlocked page.
871 test_41() {
872     [ $OSTCOUNT -lt 2 ] && \
873         skip "skipping test 41: we don't have a second OST to test with" && \
874         return
875
876     local f=$MOUNT/$tfile
877     # make sure the start of the file is ost1
878     lfs setstripe $f -s $((128 * 1024)) -i 0
879     do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
880     cancel_lru_locks osc
881     # fail ost2 and read from ost1
882     local osc2dev=`do_facet $SINGLEMDS "lctl get_param -n devices | grep ${ost2_svc}-osc-MDT0000" | awk '{print $1}'`
883     [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
884     do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
885     do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
886     do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
887     return 0
888 }
889 run_test 41 "read from a valid osc while other oscs are invalid"
890
891 # test MDS recovery after ost failure
892 test_42() {
893     blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
894     createmany -o $DIR/$tfile-%d 800
895     replay_barrier ost1
896     unlinkmany $DIR/$tfile-%d 0 400
897     debugsave
898     lctl set_param debug=-1
899     facet_failover ost1
900
901     # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
902     #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
903     #[ $blocks_after -lt $blocks ] || return 1
904     echo wait for MDS to timeout and recover
905     sleep $((TIMEOUT * 2))
906     debugrestore
907     unlinkmany $DIR/$tfile-%d 400 400
908     $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
909 }
910 run_test 42 "recovery after ost failure"
911
912 # timeout in MDS/OST recovery RPC will LBUG MDS
913 test_43() { # bug 2530
914     replay_barrier $SINGLEMDS
915
916     # OBD_FAIL_OST_CREATE_NET 0x204
917     do_facet ost1 "lctl set_param fail_loc=0x80000204"
918     fail $SINGLEMDS
919     sleep 10
920     do_facet ost1 "lctl set_param fail_loc=0"
921
922     return 0
923 }
924 run_test 43 "mds osc import failure during recovery; don't LBUG"
925
926 test_44a() {    # was test_44
927     local at_max_saved=0
928
929     mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
930     [ "$mdcdev" ] || exit 2
931
932     # adaptive timeouts slow this way down
933     if at_is_valid && at_is_enabled; then
934         at_max_saved=$(at_max_get mds)
935         at_max_set 40 mds
936     fi
937
938     for i in `seq 1 10`; do
939         echo "$i of 10 ($(date +%s))"
940         do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
941         #define OBD_FAIL_TGT_CONN_RACE     0x701
942         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
943         $LCTL --device $mdcdev recover
944         df $MOUNT
945     done
946     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
947     [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
948     return 0
949 }
950 run_test 44a "race in target handle connect"
951
952 test_44b() {
953     mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
954     [ "$mdcdev" ] || exit 2
955     for i in `seq 1 10`; do
956         echo "$i of 10 ($(date +%s))"
957         do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
958         #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
959         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
960         $LCTL --device $mdcdev recover
961         df $MOUNT
962     done
963     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
964     return 0
965 }
966 run_test 44b "race in target handle connect"
967
968 # Handle failed close
969 test_45() {
970     mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
971     [ "$mdcdev" ] || exit 2
972     $LCTL --device $mdcdev recover
973
974     multiop_bg_pause $DIR/$tfile O_c || return 1
975     pid=$!
976
977     # This will cause the CLOSE to fail before even
978     # allocating a reply buffer
979     $LCTL --device $mdcdev deactivate || return 4
980
981     # try the close
982     kill -USR1 $pid
983     wait $pid || return 1
984
985     $LCTL --device $mdcdev activate || return 5
986     sleep 1
987
988     $CHECKSTAT -t file $DIR/$tfile || return 2
989     return 0
990 }
991 run_test 45 "Handle failed close"
992
993 test_46() {
994     dmesg -c >/dev/null
995     drop_reply "touch $DIR/$tfile"
996     fail $SINGLEMDS
997     # ironically, the previous test, 45, will cause a real forced close,
998     # so just look for one for this test
999     dmesg | grep -i "force closing client file handle for $tfile" && return 1
1000     return 0
1001 }
1002 run_test 46 "Don't leak file handle after open resend (3325)"
1003
1004 test_47() { # bug 2824
1005     # create some files to make sure precreate has been done on all
1006     # OSTs. (just in case this test is run independently)
1007     createmany -o $DIR/$tfile 20  || return 1
1008
1009     # OBD_FAIL_OST_CREATE_NET 0x204
1010     fail ost1
1011     do_facet ost1 "lctl set_param fail_loc=0x80000204"
1012     df $MOUNT || return 2
1013
1014     # let the MDS discover the OST failure, attempt to recover, fail
1015     # and recover again.
1016     sleep $((3 * TIMEOUT))
1017
1018     # Without 2824, this createmany would hang
1019     createmany -o $DIR/$tfile 20 || return 3
1020     unlinkmany $DIR/$tfile 20 || return 4
1021
1022     do_facet ost1 "lctl set_param fail_loc=0"
1023     return 0
1024 }
1025 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1026
1027 test_48() {
1028     replay_barrier $SINGLEMDS
1029     createmany -o $DIR/$tfile 20  || return 1
1030     # OBD_FAIL_OST_EROFS 0x216
1031     fail $SINGLEMDS
1032     do_facet ost1 "lctl set_param fail_loc=0x80000216"
1033     df $MOUNT || return 2
1034
1035     createmany -o $DIR/$tfile 20 20 || return 2
1036     unlinkmany $DIR/$tfile 40 || return 3
1037
1038     do_facet ost1 "lctl set_param fail_loc=0"
1039     return 0
1040 }
1041 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1042
1043 test_50() {
1044     local oscdev=`do_facet $SINGLEMDS lctl get_param -n devices | grep ${ost1_svc}-osc-MDT0000 | awk '{print $1}'`
1045     [ "$oscdev" ] || return 1
1046     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1047     do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1048     # give the mds_lov_sync threads a chance to run
1049     sleep 5
1050 }
1051 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1052
1053 # b3764 timed out lock replay
1054 test_52() {
1055     touch $DIR/$tfile
1056     cancel_lru_locks mdc
1057
1058     multiop $DIR/$tfile s || return 1
1059     replay_barrier $SINGLEMDS
1060 #define OBD_FAIL_LDLM_REPLY              0x30c
1061     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1062     fail $SINGLEMDS || return 2
1063     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1064
1065     $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1066 }
1067 run_test 52 "time out lock replay (3764)"
1068
1069 # bug 3462 - simultaneous MDC requests
1070 test_53a() {
1071         mkdir -p $DIR/${tdir}-1
1072         mkdir -p $DIR/${tdir}-2
1073         multiop $DIR/${tdir}-1/f O_c &
1074         close_pid=$!
1075         # give multiop a change to open
1076         sleep 1
1077
1078         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1079         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1080         kill -USR1 $close_pid
1081         cancel_lru_locks mdc    # force the close
1082         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1083
1084         mcreate $DIR/${tdir}-2/f || return 1
1085
1086         # close should still be here
1087         [ -d /proc/$close_pid ] || return 2
1088
1089         replay_barrier_nodf $SINGLEMDS
1090         fail $SINGLEMDS
1091         wait $close_pid || return 3
1092
1093         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1094         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1095         rm -rf $DIR/${tdir}-*
1096 }
1097 run_test 53a "|X| close request while two MDC requests in flight"
1098
1099 test_53b() {
1100         mkdir -p $DIR/${tdir}-1
1101         mkdir -p $DIR/${tdir}-2
1102         multiop $DIR/${tdir}-1/f O_c &
1103         close_pid=$!
1104
1105         #define OBD_FAIL_MDS_REINT_NET 0x107
1106         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1107         mcreate $DIR/${tdir}-2/f &
1108         open_pid=$!
1109         sleep 1
1110
1111         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1112         kill -USR1 $close_pid
1113         cancel_lru_locks mdc    # force the close
1114         wait $close_pid || return 1
1115         # open should still be here
1116         [ -d /proc/$open_pid ] || return 2
1117
1118         replay_barrier_nodf $SINGLEMDS
1119         fail $SINGLEMDS
1120         wait $open_pid || return 3
1121
1122         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1123         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1124         rm -rf $DIR/${tdir}-*
1125 }
1126 run_test 53b "|X| open request while two MDC requests in flight"
1127
1128 test_53c() {
1129         mkdir -p $DIR/${tdir}-1
1130         mkdir -p $DIR/${tdir}-2
1131         multiop $DIR/${tdir}-1/f O_c &
1132         close_pid=$!
1133
1134         #define OBD_FAIL_MDS_REINT_NET 0x107
1135         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1136         mcreate $DIR/${tdir}-2/f &
1137         open_pid=$!
1138         sleep 1
1139
1140         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1141         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1142         kill -USR1 $close_pid
1143         cancel_lru_locks mdc    # force the close
1144
1145         replay_barrier_nodf $SINGLEMDS
1146         fail_nodf $SINGLEMDS
1147         wait $open_pid || return 1
1148         sleep 2
1149         # close should be gone
1150         [ -d /proc/$close_pid ] && return 2
1151         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1152
1153         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1154         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1155         rm -rf $DIR/${tdir}-*
1156 }
1157 run_test 53c "|X| open request and close request while two MDC requests in flight"
1158
1159 test_53d() {
1160         mkdir -p $DIR/${tdir}-1
1161         mkdir -p $DIR/${tdir}-2
1162         multiop $DIR/${tdir}-1/f O_c &
1163         close_pid=$!
1164         # give multiop a chance to open
1165         sleep 1
1166
1167         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1168         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1169         kill -USR1 $close_pid
1170         cancel_lru_locks mdc    # force the close
1171         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1172         mcreate $DIR/${tdir}-2/f || return 1
1173
1174         # close should still be here
1175         [ -d /proc/$close_pid ] || return 2
1176         fail $SINGLEMDS
1177         wait $close_pid || return 3
1178
1179         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1180         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1181         rm -rf $DIR/${tdir}-*
1182 }
1183 run_test 53d "|X| close reply while two MDC requests in flight"
1184
1185 test_53e() {
1186         mkdir -p $DIR/${tdir}-1
1187         mkdir -p $DIR/${tdir}-2
1188         multiop $DIR/${tdir}-1/f O_c &
1189         close_pid=$!
1190
1191         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1192         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1193         mcreate $DIR/${tdir}-2/f &
1194         open_pid=$!
1195         sleep 1
1196
1197         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1198         kill -USR1 $close_pid
1199         cancel_lru_locks mdc    # force the close
1200         wait $close_pid || return 1
1201         # open should still be here
1202         [ -d /proc/$open_pid ] || return 2
1203
1204         replay_barrier_nodf $SINGLEMDS
1205         fail $SINGLEMDS
1206         wait $open_pid || return 3
1207
1208         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1209         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1210         rm -rf $DIR/${tdir}-*
1211 }
1212 run_test 53e "|X| open reply while two MDC requests in flight"
1213
1214 test_53f() {
1215         mkdir -p $DIR/${tdir}-1
1216         mkdir -p $DIR/${tdir}-2
1217         multiop $DIR/${tdir}-1/f O_c &
1218         close_pid=$!
1219
1220         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1221         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1222         mcreate $DIR/${tdir}-2/f &
1223         open_pid=$!
1224         sleep 1
1225
1226         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1227         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1228         kill -USR1 $close_pid
1229         cancel_lru_locks mdc    # force the close
1230
1231         replay_barrier_nodf $SINGLEMDS
1232         fail_nodf $SINGLEMDS
1233         wait $open_pid || return 1
1234         sleep 2
1235         # close should be gone
1236         [ -d /proc/$close_pid ] && return 2
1237         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1238
1239         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1240         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1241         rm -rf $DIR/${tdir}-*
1242 }
1243 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1244
1245 test_53g() {
1246         mkdir -p $DIR/${tdir}-1
1247         mkdir -p $DIR/${tdir}-2
1248         multiop $DIR/${tdir}-1/f O_c &
1249         close_pid=$!
1250
1251         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1252         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1253         mcreate $DIR/${tdir}-2/f &
1254         open_pid=$!
1255         sleep 1
1256
1257         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1258         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1259         kill -USR1 $close_pid
1260         cancel_lru_locks mdc    # force the close
1261
1262         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1263         replay_barrier_nodf $SINGLEMDS
1264         fail_nodf $SINGLEMDS
1265         wait $open_pid || return 1
1266         sleep 2
1267         # close should be gone
1268         [ -d /proc/$close_pid ] && return 2
1269
1270         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1271         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1272         rm -rf $DIR/${tdir}-*
1273 }
1274 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1275
1276 test_53h() {
1277         mkdir -p $DIR/${tdir}-1
1278         mkdir -p $DIR/${tdir}-2
1279         multiop $DIR/${tdir}-1/f O_c &
1280         close_pid=$!
1281
1282         #define OBD_FAIL_MDS_REINT_NET 0x107
1283         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1284         mcreate $DIR/${tdir}-2/f &
1285         open_pid=$!
1286         sleep 1
1287
1288         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1289         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1290         kill -USR1 $close_pid
1291         cancel_lru_locks mdc    # force the close
1292         sleep 1
1293
1294         replay_barrier_nodf $SINGLEMDS
1295         fail_nodf $SINGLEMDS
1296         wait $open_pid || return 1
1297         sleep 2
1298         # close should be gone
1299         [ -d /proc/$close_pid ] && return 2
1300         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1301
1302         $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1303         $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1304         rm -rf $DIR/${tdir}-*
1305 }
1306 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1307
1308 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1309
1310 #b3761 ASSERTION(hash != 0) failed
1311 test_55() {
1312 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1313     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1314     touch $DIR/$tfile &
1315     # give touch a chance to run
1316     sleep 5
1317     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1318     rm $DIR/$tfile
1319     return 0
1320 }
1321 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1322
1323 #b3440 ASSERTION(rec->ur_fid2->id) failed
1324 test_56() {
1325     ln -s foo $DIR/$tfile
1326     replay_barrier $SINGLEMDS
1327     #drop_reply "cat $DIR/$tfile"
1328     fail $SINGLEMDS
1329     sleep 10
1330 }
1331 run_test 56 "don't replay a symlink open request (3440)"
1332
1333 #recovery one mds-ost setattr from llog
1334 test_57() {
1335 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1336     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1337     touch $DIR/$tfile
1338     replay_barrier $SINGLEMDS
1339     fail $SINGLEMDS
1340     sleep 1
1341     $CHECKSTAT -t file $DIR/$tfile || return 1
1342     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1343     rm $DIR/$tfile
1344 }
1345 run_test 57 "test recovery from llog for setattr op"
1346
1347 #recovery many mds-ost setattr from llog
1348 test_58a() {
1349     mkdir -p $DIR/$tdir
1350 #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1351     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1352     createmany -o $DIR/$tdir/$tfile-%d 2500
1353     replay_barrier $SINGLEMDS
1354     fail $SINGLEMDS
1355     sleep 2
1356     $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1357     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1358     unlinkmany $DIR/$tdir/$tfile-%d 2500
1359     rmdir $DIR/$tdir
1360 }
1361 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1362
1363 test_58b() {
1364     mount_client $MOUNT2
1365     mkdir -p $DIR/$tdir
1366     touch $DIR/$tdir/$tfile
1367     replay_barrier $SINGLEMDS
1368     setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1369     fail $SINGLEMDS
1370     VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1371     [ x$VAL = x"bar" ] || return 1
1372     rm -f $DIR/$tdir/$tfile
1373     rmdir $DIR/$tdir
1374     zconf_umount `hostname` $MOUNT2
1375 }
1376 run_test 58b "test replay of setxattr op"
1377
1378 test_58c() { # bug 16570
1379         mount_client $MOUNT2
1380         mkdir -p $DIR/$tdir
1381         touch $DIR/$tdir/$tfile
1382         drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1383                 return 1
1384         VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1385         [ x$VAL = x"bar" ] || return 2
1386         drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1387                 return 3
1388         VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1389         [ x$VAL = x"bar1" ] || return 4
1390         rm -f $DIR/$tdir/$tfile
1391         rmdir $DIR/$tdir
1392         zconf_umount `hostname` $MOUNT2
1393 }
1394 run_test 58c "resend/reconstruct setxattr op"
1395
1396 # log_commit_thread vs filter_destroy race used to lead to import use after free
1397 # bug 11658
1398 test_59() {
1399     mkdir -p $DIR/$tdir
1400     createmany -o $DIR/$tdir/$tfile-%d 200
1401     sync
1402     unlinkmany $DIR/$tdir/$tfile-%d 200
1403 #define OBD_FAIL_PTLRPC_DELAY_RECOV       0x507
1404     do_facet ost1 "lctl set_param fail_loc=0x507"
1405     fail ost1
1406     fail $SINGLEMDS
1407     do_facet ost1 "lctl set_param fail_loc=0x0"
1408     sleep 20
1409     rmdir $DIR/$tdir
1410 }
1411 run_test 59 "test log_commit_thread vs filter_destroy race"
1412
1413 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1414 # bug 12086: should no oops and No ctxt error for this test
1415 test_60() {
1416     mkdir -p $DIR/$tdir
1417     createmany -o $DIR/$tdir/$tfile-%d 200
1418     replay_barrier $SINGLEMDS
1419     unlinkmany $DIR/$tdir/$tfile-%d 0 100
1420     fail $SINGLEMDS
1421     unlinkmany $DIR/$tdir/$tfile-%d 100 100
1422     local no_ctxt=`dmesg | grep "No ctxt"`
1423     [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1424 }
1425 run_test 60 "test llog post recovery init vs llog unlink"
1426
1427 #test race  llog recovery thread vs llog cleanup
1428 test_61a() {    # was test_61
1429     mkdir $DIR/$tdir
1430     createmany -o $DIR/$tdir/$tfile-%d 800
1431     replay_barrier ost1 
1432 #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 
1433     unlinkmany $DIR/$tdir/$tfile-%d 800 
1434     set_nodes_failloc "$(osts_nodes)" 0x80000221
1435     facet_failover ost1
1436     sleep 10 
1437     fail ost1
1438     sleep 30
1439     set_nodes_failloc "$(osts_nodes)" 0x0
1440     
1441     $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1442     rmdir $DIR/$tdir
1443 }
1444 run_test 61a "test race llog recovery vs llog cleanup"
1445
1446 #test race  mds llog sync vs llog cleanup
1447 test_61b() {
1448 #   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x140
1449     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
1450     facet_failover $SINGLEMDS 
1451     sleep 10
1452     fail $SINGLEMDS
1453     do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1454 }
1455 run_test 61b "test race mds llog sync vs llog cleanup"
1456
1457 #test race  cancel cookie cb vs llog cleanup
1458 test_61c() {
1459 #   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222 
1460     touch $DIR/$tfile 
1461     set_nodes_failloc "$(osts_nodes)" 0x80000222
1462     rm $DIR/$tfile    
1463     sleep 10
1464     fail ost1
1465     set_nodes_failloc "$(osts_nodes)" 0x0
1466 }
1467 run_test 61c "test race mds llog sync vs llog cleanup"
1468
1469 test_62() { # Bug 15756 - don't mis-drop resent replay
1470     mkdir -p $DIR/$tdir
1471     replay_barrier $SINGLEMDS
1472     createmany -o $DIR/$tdir/$tfile- 25
1473 #define OBD_FAIL_TGT_REPLAY_DROP         0x706
1474     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1475     facet_failover $SINGLEMDS
1476     df $MOUNT || return 1
1477     do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1478     unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1479     return 0
1480 }
1481 run_test 62 "don't mis-drop resent replay"
1482
1483 #Adaptive Timeouts (bug 3055)
1484 AT_MAX_SET=0
1485 # Suppose that all osts have the same at_max
1486 for facet in mds client ost; do
1487     eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1488 done
1489
1490 at_start()
1491 {
1492     local at_max_new=600
1493     if ! at_is_valid; then
1494         skip "AT env is invalid"
1495         return 1
1496     fi
1497
1498     local at_max
1499
1500     for facet in mds client ost; do
1501         at_max=$(at_max_get $facet)
1502         if [ $at_max -ne $at_max_new ]; then
1503             echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1504             at_max_set $at_max_new $facet
1505             AT_MAX_SET=1
1506         fi
1507     done
1508
1509     if [ -z "$ATOLDBASE" ]; then
1510         local at_history=$(do_facet mds "find /sys/ -name at_history")
1511         [ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
1512         ATOLDBASE=$(do_facet mds "cat $at_history")
1513         # speed up the timebase so we can check decreasing AT
1514         do_facet mds "echo 8 >> $at_history"
1515         do_facet ost1 "echo 8 >> $at_history"
1516     fi
1517 }
1518
1519 test_65a() #bug 3055
1520 {
1521     at_start || return 0
1522     $LCTL dk > /dev/null
1523     debugsave
1524     sysctl -w lnet.debug="+other"
1525     # slow down a request
1526     do_facet mds sysctl -w lustre.fail_val=30000
1527 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1528     do_facet mds sysctl -w lustre.fail_loc=0x8000050a
1529     createmany -o $DIR/$tfile 10 > /dev/null
1530     unlinkmany $DIR/$tfile 10 > /dev/null
1531     # check for log message
1532     $LCTL dk | grep "Early reply #" || error "No early reply"
1533     debugrestore
1534     # client should show 30s estimates
1535     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1536     sleep 9
1537     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1538 }
1539 run_test 65a "AT: verify early replies"
1540
1541 test_65b() #bug 3055
1542 {
1543     at_start || return 0
1544     # turn on D_ADAPTTO
1545     debugsave
1546     sysctl -w lnet.debug="other trace"
1547     $LCTL dk > /dev/null
1548     # slow down bulk i/o
1549     do_facet ost1 sysctl -w lustre.fail_val=30
1550 #define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
1551     do_facet ost1 sysctl -w lustre.fail_loc=0x224
1552
1553     rm -f $DIR/$tfile
1554     lfs setstripe $DIR/$tfile --index=0 --count=1
1555     # force some real bulk transfer
1556     multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1557
1558     do_facet ost1 sysctl -w lustre.fail_loc=0
1559     # check for log message
1560     $LCTL dk | grep "Early reply #" || error "No early reply"
1561     debugrestore
1562     # client should show 30s estimates
1563     lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1564 }
1565 run_test 65b "AT: verify early replies on packed reply / bulk"
1566
1567 test_66a() #bug 3055
1568 {
1569     at_start || return 0
1570     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1571     # adjust 5s at a time so no early reply is sent (within deadline)
1572     do_facet mds "sysctl -w lustre.fail_val=5000"
1573 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1574     do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1575     createmany -o $DIR/$tfile 20 > /dev/null
1576     unlinkmany $DIR/$tfile 20 > /dev/null
1577     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1578     do_facet mds "sysctl -w lustre.fail_val=10000"
1579     do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1580     createmany -o $DIR/$tfile 20 > /dev/null
1581     unlinkmany $DIR/$tfile 20 > /dev/null
1582     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1583     do_facet mds "sysctl -w lustre.fail_loc=0"
1584     sleep 9
1585     createmany -o $DIR/$tfile 20 > /dev/null
1586     unlinkmany $DIR/$tfile 20 > /dev/null
1587     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1588     CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1589     WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1590     echo "Current MDT timeout $CUR, worst $WORST"
1591     [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1592 }
1593 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1594
1595 test_66b() #bug 3055
1596 {
1597     at_start || return 0
1598     ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1599     sysctl -w lustre.fail_val=$(($ORIG + 5))
1600 #define OBD_FAIL_PTLRPC_PAUSE_REP      0x50c
1601     sysctl -w lustre.fail_loc=0x50c
1602     ls $DIR/$tfile > /dev/null 2>&1
1603     sysctl -w lustre.fail_loc=0
1604     CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1605     WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1606     echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1607     [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1608 }
1609 run_test 66b "AT: verify net latency adjusts"
1610
1611 test_67a() #bug 3055
1612 {
1613     at_start || return 0
1614     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1615     # sleeping threads may drive values above this
1616     do_facet ost1 "sysctl -w lustre.fail_val=400"
1617 #define OBD_FAIL_PTLRPC_PAUSE_REQ    0x50a
1618     do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1619     createmany -o $DIR/$tfile 20 > /dev/null
1620     unlinkmany $DIR/$tfile 20 > /dev/null
1621     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1622     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1623     ATTEMPTS=$(($CONN2 - $CONN1))
1624     echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1625     [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1626     return 0
1627 }
1628 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1629
1630 test_67b() #bug 3055
1631 {
1632     at_start || return 0
1633     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1634 #define OBD_FAIL_OST_PAUSE_CREATE        0x223
1635     do_facet ost1 "sysctl -w lustre.fail_val=20000"
1636     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1637     cp /etc/profile $DIR/$tfile || error "cp failed"
1638     client_reconnect
1639     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1640     log "phase 2"
1641     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1642     ATTEMPTS=$(($CONN2 - $CONN1))
1643     echo "$ATTEMPTS osc reconnect attemps on instant slow"
1644     # do it again; should not timeout
1645     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1646     cp /etc/profile $DIR/$tfile || error "cp failed"
1647     do_facet ost1 "sysctl -w lustre.fail_loc=0"
1648     client_reconnect
1649     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1650     CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1651     ATTEMPTS=$(($CONN3 - $CONN2))
1652     echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1653     [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1654     return 0
1655 }
1656 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1657
1658 test_68 () #bug 13813
1659 {
1660     at_start || return 0
1661     local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1662     [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1663     local ENQ_MIN=$(cat $ldlm_enqueue_min)
1664     echo $TIMEOUT >> $ldlm_enqueue_min
1665     rm -f $DIR/${tfile}_[1-2]
1666     lfs setstripe $DIR/$tfile --index=0 --count=1
1667 #define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
1668     sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1669     sysctl -w lustre.fail_loc=0x80000312
1670     cp /etc/profile $DIR/${tfile}_1 || error "1st cp failed $?"
1671     sysctl -w lustre.fail_val=$((TIMEOUT * 3 / 2))
1672     sysctl -w lustre.fail_loc=0x80000312
1673     cp /etc/profile $DIR/${tfile}_2 || error "2nd cp failed $?"
1674     sysctl -w lustre.fail_loc=0
1675     echo $ENQ_MIN >> $ldlm_enqueue_min
1676     return 0
1677 }
1678 run_test 68 "AT: verify slowing locks"
1679
1680 if [ -n "$ATOLDBASE" ]; then
1681     at_history=$(do_facet mds "find /sys/ -name at_history")
1682     do_facet mds "echo $ATOLDBASE >> $at_history" || true
1683     do_facet ost1 "echo $ATOLDBASE >> $at_history" || true
1684 fi
1685
1686 if [ $AT_MAX_SET -ne 0 ]; then
1687     for facet in mds client ost; do
1688         var=AT_MAX_SAVE_${facet}
1689         echo restore AT on $facet to saved value ${!var}
1690         at_max_set ${!var} $facet
1691         AT_NEW=$(at_max_get $facet)
1692         echo Restored AT value on $facet $AT_NEW 
1693         [ $AT_NEW -ne ${!var} ] && \
1694             error "$facet : AT value was not restored SAVED ${!var} NEW $AT_NEW"
1695     done
1696 fi
1697
1698 # end of AT tests includes above lines
1699
1700
1701 # start multi-client tests
1702 test_70a () {
1703         [ -z "$CLIENTS" ] && \
1704                 { skip "Need two or more clients." && return; }
1705         [ $CLIENTCOUNT -lt 2 ] && \
1706                 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1707
1708         echo "mount clients $CLIENTS ..."
1709         zconf_mount_clients $CLIENTS $DIR
1710
1711         local clients=${CLIENTS//,/ }
1712         echo "Write/read files on $DIR ; clients $CLIENTS ... "
1713         for CLIENT in $clients; do
1714                 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1715                         of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1716                                 error "dd failed on $CLIENT"
1717         done
1718
1719         local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/') 
1720         for C in ${CLIENTS//,/ }; do
1721                 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1722                         error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1723                 prev_client=$C
1724         done
1725         
1726         ls $DIR
1727 }
1728 run_test 70a "check multi client t-f"
1729
1730 test_70b () {
1731         [ -z "$CLIENTS" ] && \
1732                 { skip "Need two or more clients." && return; }
1733         [ $CLIENTCOUNT -lt 2 ] && \
1734                 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1735
1736         zconf_mount_clients $CLIENTS $DIR
1737         
1738         local duration="-t 60"
1739         local cmd="rundbench 1 $duration "
1740         local PID=""
1741         for CLIENT in ${CLIENTS//,/ }; do
1742                 $PDSH $CLIENT "set -x; PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:${DBENCH_LIB} DBENCH_LIB=${DBENCH_LIB} $cmd" &
1743                 PID=$!
1744                 echo $PID >pid.$CLIENT
1745                 echo "Started load PID=`cat pid.$CLIENT`"
1746         done
1747
1748         replay_barrier $SINGLEMDS 
1749         sleep 3 # give clients a time to do operations
1750
1751         log "$TESTNAME fail mds 1"
1752         fail $SINGLEMDS
1753
1754 # wait for client to reconnect to MDS
1755         sleep $TIMEOUT
1756
1757         for CLIENT in ${CLIENTS//,/ }; do
1758                 PID=`cat pid.$CLIENT`
1759                 wait $PID
1760                 rc=$?
1761                 echo "load on ${CLIENT} returned $rc"
1762         done
1763
1764 }
1765 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1766 # end multi-client tests
1767
1768 test_80a() {
1769     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1770
1771     mkdir -p $DIR/$tdir
1772     replay_barrier mds2
1773     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1774     rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1775     fail mds2
1776     stat $DIR/$tdir
1777 }
1778 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1779
1780 test_80b() {
1781     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1782
1783     mkdir -p $DIR/$tdir
1784     replay_barrier mds1
1785     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1786     rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1787     fail mds1
1788     stat $DIR/$tdir
1789 }
1790 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1791
1792 test_81a() {
1793     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1794
1795     mkdir -p $DIR/$tdir
1796     createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1797     sleep 10
1798     $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1799     $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1800     replay_barrier mds1
1801     rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1802     fail mds1
1803     stat $DIR/$tdir/f1002
1804 }
1805 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
1806
1807 test_82a() {
1808     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1809
1810     local dir=$DIR/d82a
1811     replay_barrier mds2
1812     mkdir $dir || error "mkdir $dir failed"
1813     log "FAILOVER mds2"
1814     fail mds2
1815     stat $DIR
1816     $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1817 }
1818 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
1819
1820 test_82b() {
1821     [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1822
1823     local dir=$DIR/d82b
1824     replay_barrier mds1
1825     mkdir $dir || error "mkdir $dir failed"
1826     log "FAILOVER mds1"
1827     fail mds1
1828     stat $DIR
1829     $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1830 }
1831 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
1832
1833 equals_msg `basename $0`: test complete, cleaning up
1834 check_and_cleanup_lustre
1835 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true