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