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