Whamcloud - gitweb
b=15612
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/bash
2
3 set -e
4
5 #         bug  5494 7288 5493
6 ALWAYS_EXCEPT="24   27   52 $RECOVERY_SMALL_EXCEPT"
7
8 PTLDEBUG=${PTLDEBUG:--1}
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 . $LUSTRE/tests/test-framework.sh
11 init_test_env $@
12 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13
14 # also long tests: 19, 21a, 21e, 21f, 23, 27
15 #                                   1  2.5  2.5    4    4          (min)"
16 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17  26a  26b    50   51     57"
17
18 build_test_filter
19
20 # Allow us to override the setup if we already have a mounted system by
21 # setting SETUP=" " and CLEANUP=" "
22 SETUP=${SETUP:-""}
23 CLEANUP=${CLEANUP:-""}
24
25 cleanup_and_setup_lustre
26 rm -rf $DIR/[df][0-9]*
27
28 SAMPLE_NAME=recovery-small.junk
29 SAMPLE_FILE=$TMP/$SAMPLE_NAME
30 # make this big, else test 9 doesn't wait for bulk -- bz 5595
31 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
32
33 test_1() {
34     drop_request "mcreate $MOUNT/1"  || return 1
35     drop_reint_reply "mcreate $MOUNT/2"    || return 2
36 }
37 run_test 1 "mcreate: drop req, drop rep"
38
39 test_2() {
40     drop_request "tchmod 111 $MOUNT/2"  || return 1
41     drop_reint_reply "tchmod 666 $MOUNT/2"    || return 2
42 }
43 run_test 2 "chmod: drop req, drop rep"
44
45 test_3() {
46     drop_request "statone $MOUNT/2" || return 1
47     drop_reply "statone $MOUNT/2"   || return 2
48 }
49 run_test 3 "stat: drop req, drop rep"
50
51 test_4() {
52     do_facet client "cp /etc/inittab $MOUNT/inittab" || return 1
53     drop_request "cat $MOUNT/inittab > /dev/null"   || return 2
54     drop_reply "cat $MOUNT/inittab > /dev/null"     || return 3
55 }
56 run_test 4 "open: drop req, drop rep"
57
58 test_5() {
59     drop_request "mv $MOUNT/inittab $MOUNT/renamed" || return 1
60     drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
61     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
62 }
63 run_test 5 "rename: drop req, drop rep"
64
65 [ ! -e $MOUNT/renamed-again ] && cp /etc/inittab $MOUNT/renamed-again
66 test_6() {
67     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
68     drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
69 }
70 run_test 6 "link: drop req, drop rep"
71
72 [ ! -e $MOUNT/link1 ] && mlink $MOUNT/renamed-again $MOUNT/link1
73 [ ! -e $MOUNT/link2 ] && mlink $MOUNT/renamed-again $MOUNT/link2
74 test_7() {
75     drop_request "munlink $MOUNT/link1"   || return 1
76     drop_reint_reply "munlink $MOUNT/link2"     || return 2
77 }
78 run_test 7 "unlink: drop req, drop rep"
79
80 #bug 1423
81 test_8() {
82     drop_reint_reply "touch $MOUNT/$tfile"    || return 1
83 }
84 run_test 8 "touch: drop rep (bug 1423)"
85
86 #bug 1420
87 test_9() {
88     pause_bulk "cp /etc/profile $MOUNT/$tfile"       || return 1
89     do_facet client "cp ${SAMPLE_FILE} $MOUNT/${tfile}.2"  || return 2
90     do_facet client "sync"
91     do_facet client "rm $MOUNT/$tfile $MOUNT/${tfile}.2" || return 3
92 }
93 run_test 9 "pause bulk on OST (bug 1420)"
94
95 #bug 1521
96 test_10() {
97     do_facet client mcreate $MOUNT/$tfile        || return 1
98     drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || echo "evicted as expected"
99     # wait for the mds to evict the client
100     #echo "sleep $(($TIMEOUT*2))"
101     #sleep $(($TIMEOUT*2))
102     do_facet client touch $MOUNT/$tfile || echo "touch failed, evicted"
103     do_facet client checkstat -v -p 0777 $MOUNT/$tfile  || return 3
104     do_facet client "munlink $MOUNT/$tfile"
105 }
106 run_test 10 "finish request on server after client eviction (bug 1521)"
107
108 #bug 2460
109 # wake up a thread waiting for completion after eviction
110 test_11(){
111     do_facet client multiop $MOUNT/$tfile Ow  || return 1
112     do_facet client multiop $MOUNT/$tfile or  || return 2
113
114     cancel_lru_locks osc
115
116     do_facet client multiop $MOUNT/$tfile or  || return 3
117     drop_bl_callback multiop $MOUNT/$tfile Ow || echo "evicted as expected"
118
119     do_facet client munlink $MOUNT/$tfile  || return 4
120 }
121 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
122
123 #b=2494
124 test_12(){
125     $LCTL mark multiop $MOUNT/$tfile OS_c 
126     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x115"
127     clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
128     multiop_bg_pause $MOUNT/$tfile OS_c || return 1
129     PID=$!
130 #define OBD_FAIL_MDS_CLOSE_NET           0x115
131     kill -USR1 $PID
132     echo "waiting for multiop $PID"
133     wait $PID || return 2
134     do_facet client munlink $MOUNT/$tfile  || return 3
135 }
136 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
137
138 # Bug 113, check that readdir lost recv timeout works.
139 test_13() {
140     mkdir $MOUNT/readdir || return 1
141     touch $MOUNT/readdir/newentry || return
142 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
143     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000104"
144     ls $MOUNT/readdir || return 3
145     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
146     rm -rf $MOUNT/readdir || return 4
147 }
148 run_test 13 "mdc_readpage restart test (bug 1138)"
149
150 # Bug 113, check that readdir lost send timeout works.
151 test_14() {
152     mkdir $MOUNT/readdir
153     touch $MOUNT/readdir/newentry
154 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
155     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000106"
156     ls $MOUNT/readdir || return 1
157     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
158 }
159 run_test 14 "mdc_readpage resend test (bug 1138)"
160
161 test_15() {
162     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000128"
163     touch $DIR/$tfile && return 1
164     return 0
165 }
166 run_test 15 "failed open (-ENOMEM)"
167
168 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
169 stop_read_ahead() {
170    lctl set_param -n llite.*.max_read_ahead_mb 0
171 }
172
173 start_read_ahead() {
174    lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
175 }
176
177 test_16() {
178     do_facet client cp /etc/termcap $MOUNT
179     sync
180     stop_read_ahead
181
182 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
183     do_facet ost1 "sysctl -w lustre.fail_loc=0x80000504"
184     cancel_lru_locks osc
185     # OST bulk will time out here, client resends
186     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 1
187     do_facet ost1 sysctl -w lustre.fail_loc=0
188     # give recovery a chance to finish (shouldn't take long)
189     sleep $TIMEOUT
190     do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
191     start_read_ahead
192 }
193 run_test 16 "timeout bulk put, don't evict client (2732)"
194
195 test_17() {
196     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
197     # OST bulk will time out here, client retries
198     do_facet ost1 sysctl -w lustre.fail_loc=0x80000503
199     # need to ensure we send an RPC
200     do_facet client cp /etc/termcap $DIR/$tfile
201     sync
202
203     sleep $TIMEOUT
204     do_facet ost1 sysctl -w lustre.fail_loc=0
205     do_facet client "df $DIR"
206     # expect cmp to succeed, client resent bulk
207     do_facet client "cmp /etc/termcap $DIR/$tfile" || return 3
208     do_facet client "rm $DIR/$tfile" || return 4
209     return 0
210 }
211 run_test 17 "timeout bulk get, don't evict client (2732)"
212
213 test_18a() {
214     [ -z ${ost2_svc} ] && skip "needs 2 osts" && return 0
215
216     do_facet client mkdir -p $MOUNT/$tdir
217     f=$MOUNT/$tdir/$tfile
218
219     cancel_lru_locks osc
220     pgcache_empty || return 1
221
222     # 1 stripe on ost2
223     lfs setstripe $f -s $((128 * 1024)) -i 1 -c 1
224
225     do_facet client cp $SAMPLE_FILE $f
226     sync
227     local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
228     $LCTL --device $osc2dev deactivate || return 3
229     # my understanding is that there should be nothing in the page
230     # cache after the client reconnects?     
231     rc=0
232     pgcache_empty || rc=2
233     $LCTL --device $osc2dev activate
234     rm -f $f
235     return $rc
236 }
237 run_test 18a "manual ost invalidate clears page cache immediately"
238
239 test_18b() {
240     do_facet client mkdir -p $MOUNT/$tdir
241     f=$MOUNT/$tdir/$tfile
242     f2=$MOUNT/$tdir/${tfile}-2
243
244     cancel_lru_locks osc
245     pgcache_empty || return 1
246
247     # shouldn't have to set stripe size of count==1
248     lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
249     lfs setstripe $f2 -s $((128 * 1024)) -i 0 -c 1
250
251     do_facet client cp $SAMPLE_FILE $f
252     sync
253     ost_evict_client
254     # allow recovery to complete
255     sleep $((TIMEOUT + 2))
256     # my understanding is that there should be nothing in the page
257     # cache after the client reconnects?     
258     rc=0
259     pgcache_empty || rc=2
260     rm -f $f $f2
261     return $rc
262 }
263 run_test 18b "eviction and reconnect clears page cache (2766)"
264
265 test_18c() {
266     do_facet client mkdir -p $MOUNT/$tdir
267     f=$MOUNT/$tdir/$tfile
268     f2=$MOUNT/$tdir/${tfile}-2
269
270     cancel_lru_locks osc
271     pgcache_empty || return 1
272
273     # shouldn't have to set stripe size of count==1
274     lfs setstripe $f -s $((128 * 1024)) -i 0 -c 1
275     lfs setstripe $f2 -s $((128 * 1024)) -i 0 -c 1
276
277     do_facet client cp $SAMPLE_FILE $f
278     sync
279     ost_evict_client
280
281     # OBD_FAIL_OST_CONNECT_NET2
282     # lost reply to connect request
283     do_facet ost1 sysctl -w lustre.fail_loc=0x80000225
284     # force reconnect
285     df $MOUNT > /dev/null 2>&1
286     sleep 2
287     # my understanding is that there should be nothing in the page
288     # cache after the client reconnects?     
289     rc=0
290     pgcache_empty || rc=2
291     rm -f $f $f2
292     return $rc
293 }
294 run_test 18c "Dropped connect reply after eviction handing (14755)"
295
296 test_19a() {
297     f=$MOUNT/$tfile
298     do_facet client mcreate $f        || return 1
299     drop_ldlm_cancel "chmod 0777 $f"  || echo "evicted as expected"
300
301     do_facet client checkstat -v -p 0777 $f  || echo evicted
302     # let the client reconnect
303     sleep 5
304     do_facet client "munlink $f"
305 }
306 run_test 19a "test expired_lock_main on mds (2867)"
307
308 test_19b() {
309     f=$MOUNT/$tfile
310     do_facet client multiop $f Ow  || return 1
311     do_facet client multiop $f or  || return 2
312
313     cancel_lru_locks osc
314
315     do_facet client multiop $f or  || return 3
316     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
317
318     do_facet client munlink $f  || return 4
319 }
320 run_test 19b "test expired_lock_main on ost (2867)"
321
322 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
323         mkdir -p $DIR/$tdir
324         lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
325         multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
326         MULTI_PID=$!
327         cancel_lru_locks osc
328 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
329         do_facet ost1 sysctl -w lustre.fail_loc=0x80000308
330         kill -USR1 $MULTI_PID
331         wait $MULTI_PID
332         rc=$?
333         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
334 }
335 run_test 20a "ldlm_handle_enqueue error (should return error)" 
336
337 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
338         mkdir -p $DIR/$tdir
339         lfs setstripe $DIR/$tdir/${tfile} -i 0 -c 1
340         cancel_lru_locks osc
341 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
342         do_facet ost1 sysctl -w lustre.fail_loc=0x80000308
343         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
344                 error "didn't fail open enqueue" || true
345 }
346 run_test 20b "ldlm_handle_enqueue error (should return error)"
347
348 test_21a() {
349        mkdir -p $DIR/$tdir-1
350        mkdir -p $DIR/$tdir-2
351        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
352        close_pid=$!
353
354        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000129"
355        multiop $DIR/$tdir-2/f Oc &
356        open_pid=$!
357        sleep 1
358        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
359
360        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
361        kill -USR1 $close_pid
362        cancel_lru_locks mdc
363        wait $close_pid || return 1
364        wait $open_pid || return 2
365        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
366
367        $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
368        $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
369
370        rm -rf $DIR/$tdir-*
371 }
372 run_test 21a "drop close request while close and open are both in flight"
373
374 test_21b() {
375        mkdir -p $DIR/$tdir-1
376        mkdir -p $DIR/$tdir-2
377        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
378        close_pid=$!
379
380        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
381        mcreate $DIR/$tdir-2/f &
382        open_pid=$!
383        sleep 1
384        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
385
386        kill -USR1 $close_pid
387        cancel_lru_locks mdc
388        wait $close_pid || return 1
389        wait $open_pid || return 3
390
391        $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
392        $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
393        rm -rf $DIR/$tdir-*
394 }
395 run_test 21b "drop open request while close and open are both in flight"
396
397 test_21c() {
398        mkdir -p $DIR/$tdir-1
399        mkdir -p $DIR/$tdir-2
400        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
401        close_pid=$!
402
403        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
404        mcreate $DIR/$tdir-2/f &
405        open_pid=$!
406        sleep 3
407        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
408
409        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
410        kill -USR1 $close_pid
411        cancel_lru_locks mdc
412        wait $close_pid || return 1
413        wait $open_pid || return 2
414
415        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
416
417        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
418        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
419        rm -rf $DIR/$tdir-*
420 }
421 run_test 21c "drop both request while close and open are both in flight"
422
423 test_21d() {
424        mkdir -p $DIR/$tdir-1
425        mkdir -p $DIR/$tdir-2
426        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
427        pid=$!
428
429        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000129"
430        multiop $DIR/$tdir-2/f Oc &
431        sleep 1
432        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
433
434        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
435        kill -USR1 $pid
436        cancel_lru_locks mdc
437        wait $pid || return 1
438        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
439
440        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
441        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
442
443        rm -rf $DIR/$tdir-*
444 }
445 run_test 21d "drop close reply while close and open are both in flight"
446
447 test_21e() {
448        mkdir -p $DIR/$tdir-1
449        mkdir -p $DIR/$tdir-2
450        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
451        pid=$!
452
453        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
454        touch $DIR/$tdir-2/f &
455        sleep 1
456        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
457
458        kill -USR1 $pid
459        cancel_lru_locks mdc
460        wait $pid || return 1
461
462        sleep $TIMEOUT
463        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
464        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
465        rm -rf $DIR/$tdir-*
466 }
467 run_test 21e "drop open reply while close and open are both in flight"
468
469 test_21f() {
470        mkdir -p $DIR/$tdir-1
471        mkdir -p $DIR/$tdir-2
472        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
473        pid=$!
474
475        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
476        touch $DIR/$tdir-2/f &
477        sleep 1
478        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
479
480        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
481        kill -USR1 $pid
482        cancel_lru_locks mdc
483        wait $pid || return 1
484        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
485
486        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
487        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
488        rm -rf $DIR/$tdir-*
489 }
490 run_test 21f "drop both reply while close and open are both in flight"
491
492 test_21g() {
493        mkdir -p $DIR/$tdir-1
494        mkdir -p $DIR/$tdir-2
495        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
496        pid=$!
497
498        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
499        touch $DIR/$tdir-2/f &
500        sleep 1
501        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
502
503        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
504        kill -USR1 $pid
505        cancel_lru_locks mdc
506        wait $pid || return 1
507        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
508
509        $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
510        $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
511        rm -rf $DIR/$tdir-*
512 }
513 run_test 21g "drop open reply and close request while close and open are both in flight"
514
515 test_21h() {
516        mkdir -p $DIR/$tdir-1
517        mkdir -p $DIR/$tdir-2
518        multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
519        pid=$!
520
521        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
522        touch $DIR/$tdir-2/f &
523        touch_pid=$!
524        sleep 1
525        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
526
527        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
528        cancel_lru_locks mdc
529        kill -USR1 $pid
530        wait $pid || return 1
531        do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
532
533        wait $touch_pid || return 2
534
535        $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
536        $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
537        rm -rf $DIR/$tdir-*
538 }
539 run_test 21h "drop open request and close reply while close and open are both in flight"
540
541 # bug 3462 - multiple MDC requests
542 test_22() {
543     f1=$DIR/${tfile}-1
544     f2=$DIR/${tfile}-2
545     
546     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
547     multiop $f2 Oc &
548     close_pid=$!
549
550     sleep 1
551     multiop $f1 msu || return 1
552
553     cancel_lru_locks mdc
554     do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
555
556     wait $close_pid || return 2
557     rm -rf $f2 || return 4
558 }
559 run_test 22 "drop close request and do mknod"
560
561 test_23() { #b=4561
562     multiop_bg_pause $DIR/$tfile O_c || return 1
563     pid=$!
564     # give a chance for open
565     sleep 5
566
567     # try the close
568     drop_request "kill -USR1 $pid"
569
570     fail $SINGLEMDS
571     wait $pid || return 1
572     return 0
573 }
574 run_test 23 "client hang when close a file after mds crash"
575
576 test_24() {     # bug 2248 - eviction fails writeback but app doesn't see it
577         mkdir -p $DIR/$tdir
578         cancel_lru_locks osc
579         multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
580         MULTI_PID=$!
581         ost_evict_client
582         kill -USR1 $MULTI_PID
583         wait $MULTI_PID
584         rc=$?
585         sysctl -w lustre.fail_loc=0x0
586         client_reconnect
587         [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
588 }
589 run_test 24 "fsync error (should return error)"
590
591 test_26a() {      # was test_26 bug 5921 - evict dead exports by pinger
592 # this test can only run from a client on a separate node.
593         remote_ost || { skip "local OST" && return 0; }
594         remote_mds || { skip "local MDS" && return 0; }
595         OST_FILE=obdfilter.${ost1_svc}.num_exports
596         OST_EXP="`do_facet ost1 lctl get_param -n $OST_FILE`"
597         OST_NEXP1=`echo $OST_EXP | cut -d' ' -f2`
598         echo starting with $OST_NEXP1 OST exports
599 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
600         do_facet client sysctl -w lustre.fail_loc=0x505
601         # evictor takes up to 2.25x to evict.  But if there's a 
602         # race to start the evictor from various obds, the loser
603         # might have to wait for the next ping.
604         echo Waiting for $(($TIMEOUT * 4)) secs
605         sleep $(($TIMEOUT * 4))
606         OST_EXP="`do_facet ost1 lctl get_param -n $OST_FILE`"
607         OST_NEXP2=`echo $OST_EXP | cut -d' ' -f2`
608         echo ending with $OST_NEXP2 OST exports
609         do_facet client sysctl -w lustre.fail_loc=0x0
610         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted"
611         return 0
612 }
613 run_test 26a "evict dead exports"
614
615 test_26b() {      # bug 10140 - evict dead exports by pinger
616         client_df
617         zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
618         sleep 1 # wait connections being established
619         MDS_FILE=mdt.${mds1_svc}.num_exports
620         MDS_NEXP1="`do_facet $SINGLEMDS lctl get_param -n $MDS_FILE | cut -d' ' -f2`"
621         OST_FILE=obdfilter.${ost1_svc}.num_exports
622         OST_NEXP1="`do_facet ost1 lctl get_param -n $OST_FILE | cut -d' ' -f2`"
623         echo starting with $OST_NEXP1 OST and $MDS_NEXP1 MDS exports
624         zconf_umount `hostname` $MOUNT2 -f
625         # evictor takes up to 2.25x to evict.  But if there's a 
626         # race to start the evictor from various obds, the loser
627         # might have to wait for the next ping.
628         echo Waiting for $(($TIMEOUT * 4)) secs
629         sleep $(($TIMEOUT * 4))
630         OST_NEXP2="`do_facet ost1 lctl get_param -n $OST_FILE | cut -d' ' -f2`"
631         MDS_NEXP2="`do_facet $SINGLEMDS lctl get_param -n $MDS_FILE | cut -d' ' -f2`"
632         echo ending with $OST_NEXP2 OST and $MDS_NEXP2 MDS exports
633         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted from OST"
634         [ $MDS_NEXP1 -le $MDS_NEXP2 ] && error "client not evicted from MDS"
635         return 0
636 }
637 run_test 26b "evict dead exports"
638
639 test_27() {
640         remote_mds && { skip "remote MDS" && return 0; }
641         mkdir -p $DIR/$tdir
642         writemany -q -a $DIR/$tdir/$tfile 0 5 &
643         CLIENT_PID=$!
644         sleep 1
645         FAILURE_MODE="SOFT"
646         facet_failover $SINGLEMDS
647 #define OBD_FAIL_OSC_SHUTDOWN            0x407
648         sysctl -w lustre.fail_loc=0x80000407
649         # need to wait for reconnect
650         echo -n waiting for fail_loc
651         while [ `sysctl -n lustre.fail_loc` -eq -2147482617 ]; do
652             sleep 1
653             echo -n .
654         done
655         facet_failover $SINGLEMDS
656         #no crashes allowed!
657         kill -USR1 $CLIENT_PID
658         wait $CLIENT_PID 
659         true
660 }
661 run_test 27 "fail LOV while using OSC's"
662
663 test_28() {      # bug 6086 - error adding new clients
664         do_facet client mcreate $MOUNT/$tfile       || return 1
665         drop_bl_callback "chmod 0777 $MOUNT/$tfile" ||echo "evicted as expected"
666         #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
667         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012f"
668         # fail once (evicted), reconnect fail (fail_loc), ok
669         df || (sleep 10; df) || (sleep 10; df) || error "reconnect failed"
670         rm -f $MOUNT/$tfile
671         fail $SINGLEMDS         # verify MDS last_rcvd can be loaded
672 }
673 run_test 28 "handle error adding new clients (bug 6086)"
674
675 test_50() {
676         mkdir -p $DIR/$tdir
677         # put a load of file creates/writes/deletes
678         writemany -q $DIR/$tdir/$tfile 0 5 &
679         CLIENT_PID=$!
680         echo writemany pid $CLIENT_PID
681         sleep 10
682         FAILURE_MODE="SOFT"
683         fail $SINGLEMDS
684         # wait for client to reconnect to MDS
685         sleep 60
686         fail $SINGLEMDS
687         sleep 60
688         fail $SINGLEMDS
689         # client process should see no problems even though MDS went down
690         sleep $TIMEOUT
691         kill -USR1 $CLIENT_PID
692         wait $CLIENT_PID 
693         rc=$?
694         echo writemany returned $rc
695         #these may fail because of eviction due to slow AST response.
696         [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
697 }
698 run_test 50 "failover MDS under load"
699
700 test_51() {
701         mkdir -p $DIR/$tdir
702         # put a load of file creates/writes/deletes
703         writemany -q $DIR/$tdir/$tfile 0 5 &
704         CLIENT_PID=$!
705         sleep 1
706         FAILURE_MODE="SOFT"
707         facet_failover $SINGLEMDS
708         # failover at various points during recovery
709         SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
710         echo will failover at $SEQ
711         for i in $SEQ
712           do
713           echo failover in $i sec
714           sleep $i
715           facet_failover $SINGLEMDS
716         done
717         # client process should see no problems even though MDS went down
718         # and recovery was interrupted
719         sleep $TIMEOUT
720         kill -USR1 $CLIENT_PID
721         wait $CLIENT_PID 
722         rc=$?
723         echo writemany returned $rc
724         [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
725 }
726 run_test 51 "failover MDS during recovery"
727
728 test_52_guts() {
729         do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
730         CLIENT_PID=$!
731         echo writemany pid $CLIENT_PID
732         sleep 10
733         FAILURE_MODE="SOFT"
734         fail ost1
735         rc=0
736         wait $CLIENT_PID || rc=$?
737         # active client process should see an EIO for down OST
738         [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
739         # but timing or failover setup may allow success
740         [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
741         echo "writemany returned $rc"
742         return $rc
743 }
744
745 test_52() {
746         mkdir -p $DIR/$tdir
747         test_52_guts
748         rc=$?
749         [ $rc -ne 0 ] && { return $rc; }
750         # wait for client to reconnect to OST
751         sleep 30
752         test_52_guts
753         rc=$?
754         [ $rc -ne 0 ] && { return $rc; }
755         sleep 30
756         test_52_guts
757         rc=$?
758         client_reconnect
759         #return $rc
760 }
761 run_test 52 "failover OST under load"
762
763 # test of open reconstruct
764 test_53() {
765         touch $DIR/$tfile
766         drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
767                 return 2
768 }
769 run_test 53 "touch: drop rep"
770
771 test_54() {
772         zconf_mount `hostname` $MOUNT2
773         touch $DIR/$tfile
774         touch $DIR2/$tfile.1
775         sleep 10
776         cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
777         fail $SINGLEMDS
778         umount $MOUNT2
779         ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
780         [ x"$ERROR" == x ] || error "back in time occured"
781 }
782 run_test 54 "back in time"
783
784 # bug 11330 - liblustre application death during I/O locks up OST
785 test_55() {
786         remote_ost && { skip "remote OST" && return 0; }
787
788         mkdir -p $DIR/$tdir
789
790         # first dd should be finished quickly
791         dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4  &
792         DDPID=$!
793         count=0
794         echo  "step1: testing ......"
795         while [ true ]; do
796             if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
797             count=$[count+1]
798             if [ $count -gt 64 ]; then
799                 error "dd should be finished!"
800             fi
801             sleep 1
802         done    
803         echo "(dd_pid=$DDPID, time=$count)successful"
804
805         #define OBD_FAIL_OST_DROP_REQ            0x21d
806         do_facet ost sysctl -w lustre.fail_loc=0x0000021d
807         # second dd will be never finished
808         dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4  &        
809         DDPID=$!
810         count=0
811         echo  "step2: testing ......"
812         while [ $count -le 64 ]; do
813             dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"            
814             if [ -z  $dd_name ]; then 
815                 ls -l $DIR/$tdir
816                 echo  "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
817                 error "dd shouldn't be finished!"
818             fi
819             count=$[count+1]
820             sleep 1
821         done    
822         echo "(dd_pid=$DDPID, time=$count)successful"
823
824         #Recover fail_loc and dd will finish soon
825         do_facet ost sysctl -w lustre.fail_loc=0
826         count=0
827         echo  "step3: testing ......"
828         while [ true ]; do
829             if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
830             count=$[count+1]
831             if [ $count -gt 500 ]; then
832                 error "dd should be finished!"
833             fi
834             sleep 1
835         done    
836         echo "(dd_pid=$DDPID, time=$count)successful"
837
838         rm -rf $DIR/$tdir
839 }
840 run_test 55 "ost_brw_read/write drops timed-out read/write request"
841
842 test_56() { # b=11277
843 #define OBD_FAIL_MDS_RESEND      0x136
844         touch $DIR/$tfile
845         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000136"
846         stat $DIR/$tfile
847         do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
848         rm -f $DIR/$tfile
849 }
850 run_test 56 "do not allow reconnect to busy exports"
851
852 test_57_helper() {
853         # no oscs means no client or mdt 
854         while lctl get_param osc.*.* > /dev/null 2>&1; do
855                 : # loop until proc file is removed
856         done
857 }
858
859 test_57() { # bug 10866
860         test_57_helper &
861         pid=$!
862         sleep 1
863 #define OBD_FAIL_LPROC_REMOVE            0xB00
864         sysctl -w lustre.fail_loc=0x80000B00
865         zconf_umount `hostname` $DIR
866         sysctl -w lustre.fail_loc=0x80000B00
867         fail_abort $SINGLEMDS
868         kill -9 $pid
869         sysctl -w lustre.fail_loc=0
870         mount_client $DIR
871         do_facet client "df $DIR"
872 }
873 run_test 57 "read procfs entries causes kernel crash"
874
875 test_58() { # bug 11546
876 #define OBD_FAIL_MDC_ENQUEUE_PAUSE        0x801
877         touch $MOUNT/$tfile
878         ls -la $MOUNT/$tfile
879         sysctl -w lustre.fail_loc=0x80000801
880         cp $MOUNT/$tfile /dev/null &
881         pid=$!
882         sleep 1
883         sysctl -w lustre.fail_loc=0
884         drop_bl_callback rm -f $MOUNT/$tfile
885         wait $pid
886         do_facet client "df $DIR"
887 }
888 run_test 58 "Eviction in the middle of open RPC reply processing"
889
890 test_59() { # bug 10589
891         zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
892         echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
893 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE  0x311
894         sysctl -w lustre.fail_loc=0x311
895         writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
896         [ $? = 0 ] || error "dd write failed"
897         writes=$(echo $writes | awk  -F '+' '/out/ {print $1}')
898         sysctl -w lustre.fail_loc=0
899         sync
900         zconf_umount `hostname` $MOUNT2 -f
901         reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
902         [ $? = 0 ] || error "dd read failed"
903         reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
904         [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
905 }
906 run_test 59 "Read cancel race on client eviction"
907
908 equals_msg `basename $0`: test complete, cleaning up
909 check_and_cleanup_lustre
910 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true