Whamcloud - gitweb
Branch b1_4_mountconf
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -e
4
5 #         bug  2986 5494 7288
6 ALWAYS_EXCEPT="20b  24   27 $RECOVERY_SMALL_EXCEPT"
7
8 LUSTRE=${LUSTRE:-`dirname $0`/..}
9
10 . $LUSTRE/tests/test-framework.sh
11
12 init_test_env $@
13
14 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
15
16 build_test_filter
17
18
19 # Allow us to override the setup if we already have a mounted system by
20 # setting SETUP=" " and CLEANUP=" "
21 SETUP=${SETUP:-"setup"}
22 CLEANUP=${CLEANUP:-"cleanup"}
23 FORCE=${FORCE:-"-f"}
24
25 make_config() {
26     rm -f $XMLCONFIG
27     add_mds mds --dev $MDSDEV --size $MDSSIZE
28     add_lov lov1 mds --stripe_sz $STRIPE_BYTES \
29         --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
30     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
31     add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
32     add_client client mds --lov lov1 --path $MOUNT
33 }
34
35 setup() {
36     make_config
37     start ost --reformat $OSTLCONFARGS 
38     start ost2 --reformat $OSTLCONFARGS 
39     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
40     start mds $MDSLCONFARGS --reformat
41     grep " $MOUNT " /proc/mounts || zconf_mount `hostname`  $MOUNT
42 }
43
44 cleanup() {
45     zconf_umount `hostname` $MOUNT
46     stop mds ${FORCE} $MDSLCONFARGS
47     stop ost2 ${FORCE}
48     stop ost ${FORCE} --dump $TMP/recovery-small-`hostname`.log
49 }
50
51 replay() {
52     do_mds "sync"
53     do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
54     do_client "$1" &
55     shutdown_mds -f
56     start_mds
57     wait
58     do_client "df -h $MOUNT" # trigger failover, if we haven't already
59 }
60
61 if [ ! -z "$EVAL" ]; then
62     eval "$EVAL"
63     exit $?
64 fi
65
66 if [ "$ONLY" == "cleanup" ]; then
67     sysctl -w lnet.debug=0 || true
68     FORCE=--force cleanup
69     exit
70 fi
71
72 REFORMAT=--reformat $SETUP
73 unset REFORMAT
74
75 [ "$ONLY" == "setup" ] && exit
76
77 test_1() {
78     drop_request "mcreate $MOUNT/1"  || return 1
79     drop_reint_reply "mcreate $MOUNT/2"    || return 2
80 }
81 run_test 1 "mcreate: drop req, drop rep"
82
83 test_2() {
84     drop_request "tchmod 111 $MOUNT/2"  || return 1
85     drop_reint_reply "tchmod 666 $MOUNT/2"    || return 2
86 }
87 run_test 2 "chmod: drop req, drop rep"
88
89 test_3() {
90     drop_request "statone $MOUNT/2" || return 1
91     drop_reply "statone $MOUNT/2"   || return 2
92 }
93 run_test 3 "stat: drop req, drop rep"
94
95 test_4() {
96     do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
97     drop_request "cat $MOUNT/resolv.conf > /dev/null"   || return 2
98     drop_reply "cat $MOUNT/resolv.conf > /dev/null"     || return 3
99 }
100 run_test 4 "open: drop req, drop rep"
101
102 test_5() {
103     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
104     drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
105     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
106 }
107 run_test 5 "rename: drop req, drop rep"
108
109 test_6() {
110     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
111     drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
112 }
113 run_test 6 "link: drop req, drop rep"
114
115 test_7() {
116     drop_request "munlink $MOUNT/link1"   || return 1
117     drop_reint_reply "munlink $MOUNT/link2"     || return 2
118 }
119 run_test 7 "unlink: drop req, drop rep"
120
121 #bug 1423
122 test_8() {
123     drop_reint_reply "touch $MOUNT/renamed"    || return 1
124 }
125 run_test 8 "touch: drop rep (bug 1423)"
126
127 #bug 1420
128 test_9() {
129     pause_bulk "cp /etc/profile $MOUNT"       || return 1
130     do_facet client "cp /etc/termcap $MOUNT"  || return 2
131     do_facet client "sync"
132     do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
133 }
134 run_test 9 "pause bulk on OST (bug 1420)"
135
136 #bug 1521
137 test_10() {
138     do_facet client mcreate $MOUNT/$tfile        || return 1
139     drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || return 2
140     # wait for the mds to evict the client
141     #echo "sleep $(($TIMEOUT*2))"
142     #sleep $(($TIMEOUT*2))
143     do_facet client touch $MOUNT/$tfile || echo "touch failed, evicted"
144     do_facet client checkstat -v -p 0777 $MOUNT/$tfile  || return 3
145     do_facet client "munlink $MOUNT/$tfile"
146 }
147 run_test 10 "finish request on server after client eviction (bug 1521)"
148
149 #bug 2460
150 # wake up a thread waiting for completion after eviction
151 test_11(){
152     do_facet client multiop $MOUNT/$tfile Ow  || return 1
153     do_facet client multiop $MOUNT/$tfile or  || return 2
154
155     cancel_lru_locks OSC
156
157     do_facet client multiop $MOUNT/$tfile or  || return 3
158     drop_bl_callback multiop $MOUNT/$tfile Ow  || 
159         echo "client evicted, as expected"
160
161     do_facet client munlink $MOUNT/$tfile  || return 4
162 }
163 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
164
165 #b=2494
166 test_12(){
167     $LCTL mark multiop $MOUNT/$tfile OS_c 
168     do_facet mds "sysctl -w lustre.fail_loc=0x115"
169     clear_failloc mds $((TIMEOUT * 2)) &
170     multiop $MOUNT/$tfile OS_c  &
171     PID=$!
172 #define OBD_FAIL_MDS_CLOSE_NET           0x115
173     sleep 2
174     kill -USR1 $PID
175     echo "waiting for multiop $PID"
176     wait $PID || return 2
177     do_facet client munlink $MOUNT/$tfile  || return 3
178 }
179 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
180
181 # Bug 113, check that readdir lost recv timeout works.
182 test_13() {
183     mkdir /mnt/lustre/readdir || return 1
184     touch /mnt/lustre/readdir/newentry || return
185 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
186     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
187     ls /mnt/lustre/readdir || return 3
188     do_facet mds "sysctl -w lustre.fail_loc=0"
189     rm -rf /mnt/lustre/readdir || return 4
190 }
191 run_test 13 "mdc_readpage restart test (bug 1138)"
192
193 # Bug 113, check that readdir lost send timeout works.
194 test_14() {
195     mkdir /mnt/lustre/readdir
196     touch /mnt/lustre/readdir/newentry
197 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
198     do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
199     ls /mnt/lustre/readdir || return 1
200     do_facet mds "sysctl -w lustre.fail_loc=0"
201 }
202 run_test 14 "mdc_readpage resend test (bug 1138)"
203
204 test_15() {
205     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
206     touch $DIR/$tfile && return 1
207     return 0
208 }
209 run_test 15 "failed open (-ENOMEM)"
210
211 READ_AHEAD=`cat /proc/fs/lustre/llite/*/max_read_ahead_mb | head -n 1`
212 stop_read_ahead() {
213    for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do 
214       echo 0 > $f
215    done
216 }
217
218 start_read_ahead() {
219    for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do 
220       echo $READ_AHEAD > $f
221    done
222 }
223
224 test_16() {
225     do_facet client cp /etc/termcap $MOUNT
226     sync
227     stop_read_ahead
228
229 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
230     sysctl -w lustre.fail_loc=0x80000504
231     cancel_lru_locks OSC
232     # will get evicted here
233     do_facet client "cmp /etc/termcap $MOUNT/termcap"  && return 1
234     sysctl -w lustre.fail_loc=0
235     # give recovery a chance to finish (shouldn't take long)
236     sleep $TIMEOUT
237     do_facet client "cmp /etc/termcap $MOUNT/termcap"  || return 2
238     start_read_ahead
239 }
240 run_test 16 "timeout bulk put, evict client (2732)"
241
242 test_17() {
243     # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
244     # client will get evicted here
245     sysctl -w lustre.fail_loc=0x80000503
246     # need to ensure we send an RPC
247     do_facet client cp /etc/termcap $DIR/$tfile
248     sync
249
250     sleep $TIMEOUT
251     sysctl -w lustre.fail_loc=0
252     do_facet client "df $DIR"
253     # expect cmp to fail
254     do_facet client "cmp /etc/termcap $DIR/$tfile"  && return 3
255     do_facet client "rm $DIR/$tfile" || return 4
256     return 0
257 }
258 run_test 17 "timeout bulk get, evict client (2732)"
259
260 test_18a() {
261     do_facet client mkdir -p $MOUNT/$tdir
262     f=$MOUNT/$tdir/$tfile
263
264     cancel_lru_locks OSC
265     pgcache_empty || return 1
266
267     # 1 stripe on ost2
268     lfs setstripe $f $((128 * 1024)) 1 1
269
270     do_facet client cp /etc/termcap $f
271     sync
272     local osc2_dev=`$LCTL device_list | \
273         awk '(/ost2.*client_facet/){print $4}' `
274     $LCTL --device %$osc2_dev deactivate
275     # my understanding is that there should be nothing in the page
276     # cache after the client reconnects?     
277     rc=0
278     pgcache_empty || rc=2
279     $LCTL --device %$osc2_dev activate
280     rm -f $f
281     return $rc
282 }
283 run_test 18a "manual ost invalidate clears page cache immediately"
284
285 test_18b() {
286     do_facet client mkdir -p $MOUNT/$tdir
287     f=$MOUNT/$tdir/$tfile
288     f2=$MOUNT/$tdir/${tfile}-2
289
290     cancel_lru_locks OSC
291     pgcache_empty || return 1
292
293     # shouldn't have to set stripe size of count==1
294     lfs setstripe $f $((128 * 1024)) 0 1
295     lfs setstripe $f2 $((128 * 1024)) 0 1
296
297     do_facet client cp /etc/termcap $f
298     sync
299     # just use this write to trigger the client's eviction from the ost
300 # OBD_FAIL_PTLRPC_BULK_GET_NET|OBD_FAIL_ONCE
301     sysctl -w lustre.fail_loc=0x80000503
302     do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
303     sync
304     sysctl -w lustre.fail_loc=0
305     # allow recovery to complete
306     sleep $((TIMEOUT + 2))
307     # my understanding is that there should be nothing in the page
308     # cache after the client reconnects?     
309     rc=0
310     pgcache_empty || rc=2
311     rm -f $f $f2
312     return $rc
313 }
314 run_test 18b "eviction and reconnect clears page cache (2766)"
315
316 test_19a() {
317     f=$MOUNT/$tfile
318     do_facet client mcreate $f        || return 1
319     drop_ldlm_cancel "chmod 0777 $f"  || echo evicted
320
321     do_facet client checkstat -v -p 0777 $f  || echo evicted
322     # let the client reconnect
323     sleep 5
324     do_facet client "munlink $f"
325 }
326 run_test 19a "test expired_lock_main on mds (2867)"
327
328 test_19b() {
329     f=$MOUNT/$tfile
330     do_facet client multiop $f Ow  || return 1
331     do_facet client multiop $f or  || return 2
332
333     cancel_lru_locks OSC
334
335     do_facet client multiop $f or  || return 3
336     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
337
338     do_facet client munlink $f  || return 4
339 }
340 run_test 19b "test expired_lock_main on ost (2867)"
341
342 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
343         mkdir -p $DIR/$tdir
344         multiop $DIR/$tdir/${tfile} O_wc &
345         MULTI_PID=$!
346         sleep 1
347         cancel_lru_locks OSC
348 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
349         do_facet ost sysctl -w lustre.fail_loc=0x80000308
350         kill -USR1 $MULTI_PID
351         wait $MULTI_PID
352         rc=$?
353         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
354 }
355 run_test 20a "ldlm_handle_enqueue error (should return error)" 
356
357 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
358         mkdir -p $DIR/$tdir
359         touch $DIR/$tdir/${tfile}
360         cancel_lru_locks OSC
361 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
362         do_facet ost sysctl -w lustre.fail_loc=0x80000308
363         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
364                 error "didn't fail open enqueue" || true
365 }
366 run_test 20b "ldlm_handle_enqueue error (should return error)"
367
368 #b_cray run_test 21a "drop close request while close and open are both in flight"
369 #b_cray run_test 21b "drop open request while close and open are both in flight"
370 #b_cray run_test 21c "drop both request while close and open are both in flight"
371 #b_cray run_test 21d "drop close reply while close and open are both in flight"
372 #b_cray run_test 21e "drop open reply while close and open are both in flight"
373 #b_cray run_test 21f "drop both reply while close and open are both in flight"
374 #b_cray run_test 21g "drop open reply and close request while close and open are both in flight"
375 #b_cray run_test 21h "drop open request and close reply while close and open are both in flight"
376 #b_cray run_test 22 "drop close request and do mknod"
377 #b_cray run_test 23 "client hang when close a file after mds crash"
378
379 test_24() {     # bug 2248 - eviction fails writeback but app doesn't see it
380         mkdir -p $DIR/$tdir
381         cancel_lru_locks OSC
382         multiop $DIR/$tdir/$tfile Owy_wyc &
383         MULTI_PID=$!
384         usleep 500
385 # OBD_FAIL_PTLRPC_BULK_GET_NET|OBD_FAIL_ONCE
386         sysctl -w lustre.fail_loc=0x80000503
387         usleep 500
388         kill -USR1 $MULTI_PID
389         wait $MULTI_PID
390         rc=$?
391         sysctl -w lustre.fail_loc=0x0
392         client_reconnect
393         [ $rc -eq 0 ] && error "multiop didn't fail fsync: rc $rc" || true
394 }
395 run_test 24 "fsync error (should return error)"
396
397 test_26() {      # bug 5921 - evict dead exports 
398 # this test can only run from a client on a separate node.
399         [ "`lsmod | grep obdfilter`" ] && \
400             echo "skipping test 26 (local OST)" && return
401         [ "`lsmod | grep mds`" ] && \
402             echo "skipping test 26 (local MDS)" && return
403         OST_FILE=/proc/fs/lustre/obdfilter/ost_svc/num_exports
404         OST_EXP="`do_facet ost cat $OST_FILE`"
405         OST_NEXP1=`echo $OST_EXP | cut -d' ' -f2`
406         echo starting with $OST_NEXP1 OST exports
407 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
408         do_facet client sysctl -w lustre.fail_loc=0x505
409         # evictor takes up to 2.25x to evict.  But if there's a 
410         # race to start the evictor from various obds, the loser
411         # might have to wait for the next ping.
412         echo Waiting for $(($TIMEOUT * 4)) secs
413         sleep $(($TIMEOUT * 4))
414         OST_EXP="`do_facet ost cat $OST_FILE`"
415         OST_NEXP2=`echo $OST_EXP | cut -d' ' -f2`
416         echo ending with $OST_NEXP2 OST exports
417         do_facet client sysctl -w lustre.fail_loc=0x0
418         [ $OST_NEXP1 -le $OST_NEXP2 ] && error "client not evicted"
419         return 0
420 }
421 run_test 26 "evict dead exports"
422
423 test_27() {
424         [ "`lsmod | grep mds`" ] || \
425             { echo "skipping test 27 (non-local MDS)" && return 0; }
426         mkdir -p $DIR/$tdir
427         writemany -q -a $DIR/$tdir/$tfile 0 5 &
428         CLIENT_PID=$!
429         sleep 1
430         FAILURE_MODE="SOFT"
431         facet_failover mds
432 #define OBD_FAIL_OSC_SHUTDOWN            0x407
433         sysctl -w lustre.fail_loc=0x80000407
434         # need to wait for reconnect
435         echo -n waiting for fail_loc
436         while [ `sysctl -n lustre.fail_loc` -eq -2147482617 ]; do
437             sleep 1
438             echo -n .
439         done
440         facet_failover mds
441         #no crashes allowed!
442         kill -USR1 $CLIENT_PID
443         wait $CLIENT_PID 
444         true
445 }
446 run_test 27 "fail LOV while using OSC's"
447
448 test_28() {      # bug 6086 - error adding new clients
449         do_facet client mcreate $MOUNT/$tfile        || return 1
450         drop_bl_callback "chmod 0777 $MOUNT/$tfile"  || return 2
451         #define OBD_FAIL_MDS_ADD_CLIENT 0x12f
452         do_facet mds sysctl -w lustre.fail_loc=0x8000012f
453         # fail once (evicted), reconnect fail (fail_loc), ok
454         df || (sleep 1; df) || (sleep 1; df) || error "reconnect failed"
455         rm -f $MOUNT/$tfile
456         fail mds                # verify MDS last_rcvd can be loaded
457 }
458 run_test 28 "handle error adding new clients (bug 6086)"
459
460 test_50() {
461         mkdir -p $DIR/$tdir
462         # put a load of file creates/writes/deletes
463         writemany -q $DIR/$tdir/$tfile 0 5 &
464         CLIENT_PID=$!
465         echo writemany pid $CLIENT_PID
466         sleep 10
467         FAILURE_MODE="SOFT"
468         fail mds
469         # wait for client to reconnect to MDS
470         sleep 60
471         fail mds
472         sleep 60
473         fail mds
474         # client process should see no problems even though MDS went down
475         sleep $TIMEOUT
476         kill -USR1 $CLIENT_PID
477         wait $CLIENT_PID 
478         rc=$?
479         echo writemany returned $rc
480         #these may fail because of eviction due to slow AST response.
481         return $rc
482 }
483 run_test 50 "failover MDS under load"
484
485 test_51() {
486         mkdir -p $DIR/$tdir
487         # put a load of file creates/writes/deletes
488         writemany -q $DIR/$tdir/$tfile 0 5 &
489         CLIENT_PID=$!
490         sleep 1
491         FAILURE_MODE="SOFT"
492         facet_failover mds
493         # failover at various points during recovery
494         SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
495         echo will failover at $SEQ
496         for i in $SEQ
497           do
498           echo failover in $i sec
499           sleep $i
500           facet_failover mds
501         done
502         # client process should see no problems even though MDS went down
503         # and recovery was interrupted
504         sleep $TIMEOUT
505         kill -USR1 $CLIENT_PID
506         wait $CLIENT_PID 
507         rc=$?
508         echo writemany returned $rc
509         return $rc
510 }
511 run_test 51 "failover MDS during recovery"
512
513 test_52_guts() {
514         do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
515         CLIENT_PID=$!
516         echo writemany pid $CLIENT_PID
517         sleep 10
518         FAILURE_MODE="SOFT"
519         fail ost
520         rc=0
521         wait $CLIENT_PID || rc=$?
522         # active client process should see an EIO for down OST
523         [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
524         # but timing or failover setup may allow success
525         [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
526         echo "writemany returned $rc"
527         return $rc
528 }
529
530 test_52() {
531         mkdir -p $DIR/$tdir
532         test_52_guts
533         rc=$?
534         [ $rc -ne 0 ] && { return $rc; }
535         # wait for client to reconnect to OST
536         sleep 30
537         test_52_guts
538         rc=$?
539         [ $rc -ne 0 ] && { return $rc; }
540         sleep 30
541         test_52_guts
542         rc=$?
543         client_reconnect
544         #return $rc
545 }
546 run_test 52 "failover OST under load"
547
548
549 FORCE=--force $CLEANUP