6 ALWAYS_EXCEPT="24 52 $RECOVERY_SMALL_EXCEPT"
8 export MULTIOP=${MULTIOP:-multiop}
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 require_dsh_mds || exit 0
18 # also long tests: 19, 21a, 21e, 21f, 23, 27
19 # 1 2.5 2.5 4 4 (min)"
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
24 # Allow us to override the setup if we already have a mounted system by
25 # setting SETUP=" " and CLEANUP=" "
27 CLEANUP=${CLEANUP:-""}
29 check_and_setup_lustre
32 rm -rf $DIR/[df][0-9]*
35 drop_request "mcreate $DIR/f1" || return 1
36 drop_reint_reply "mcreate $DIR/f2" || return 2
38 run_test 1 "mcreate: drop req, drop rep"
41 drop_request "tchmod 111 $DIR/f2" || return 1
42 drop_reint_reply "tchmod 666 $DIR/f2" || return 2
44 run_test 2 "chmod: drop req, drop rep"
47 drop_request "statone $DIR/f2" || return 1
48 drop_reply "statone $DIR/f2" || return 2
50 run_test 3 "stat: drop req, drop rep"
52 SAMPLE_NAME=f0.recovery-small.junk
53 SAMPLE_FILE=$TMP/$SAMPLE_NAME
54 # make this big, else test 9 doesn't wait for bulk -- bz 5595
55 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=4
58 do_facet client "cp $SAMPLE_FILE $DIR/$SAMPLE_NAME" || return 1
59 drop_request "cat $DIR/$SAMPLE_NAME > /dev/null" || return 2
60 drop_reply "cat $DIR/$SAMPLE_NAME > /dev/null" || return 3
62 run_test 4 "open: drop req, drop rep"
64 RENAMED_AGAIN=$DIR/f0.renamed-again
67 drop_request "mv $DIR/$SAMPLE_NAME $DIR/$tfile-renamed" || return 1
68 drop_reint_reply "mv $DIR/$tfile-renamed $RENAMED_AGAIN" || return 2
69 do_facet client "checkstat -v $RENAMED_AGAIN" || return 3
71 run_test 5 "rename: drop req, drop rep"
73 [ ! -e $RENAMED_AGAIN ] && cp $SAMPLE_FILE $RENAMED_AGAIN
78 drop_request "mlink $RENAMED_AGAIN $LINK1" || return 1
79 drop_reint_reply "mlink $RENAMED_AGAIN $LINK2" || return 2
81 run_test 6 "link: drop req, drop rep"
83 [ ! -e $LINK1 ] && mlink $RENAMED_AGAIN $LINK1
84 [ ! -e $LINK2 ] && mlink $RENAMED_AGAIN $LINK2
86 drop_request "munlink $LINK1" || return 1
87 drop_reint_reply "munlink $LINK2" || return 2
89 run_test 7 "unlink: drop req, drop rep"
93 drop_reint_reply "touch $DIR/$tfile" || return 1
95 run_test 8 "touch: drop rep (bug 1423)"
99 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
101 pause_bulk "cp /etc/profile $DIR/$tfile" || return 1
102 do_facet client "cp $SAMPLE_FILE $DIR/${tfile}.2" || return 2
103 do_facet client "sync"
104 do_facet client "rm $DIR/$tfile $DIR/${tfile}.2" || return 3
106 run_test 9 "pause bulk on OST (bug 1420)"
110 do_facet client mcreate $DIR/$tfile || return 1
111 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
112 # wait for the mds to evict the client
113 #echo "sleep $(($TIMEOUT*2))"
114 #sleep $(($TIMEOUT*2))
115 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
116 do_facet client checkstat -v -p 0777 $DIR/$tfile || return 3
117 do_facet client "munlink $DIR/$tfile"
119 run_test 10 "finish request on server after client eviction (bug 1521)"
122 # wake up a thread waiting for completion after eviction
124 do_facet client $MULTIOP $DIR/$tfile Ow || return 1
125 do_facet client $MULTIOP $DIR/$tfile or || return 2
129 do_facet client $MULTIOP $DIR/$tfile or || return 3
130 drop_bl_callback $MULTIOP $DIR/$tfile Ow || echo "evicted as expected"
132 do_facet client munlink $DIR/$tfile || return 4
134 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
138 $LCTL mark $MULTIOP $DIR/$tfile OS_c
139 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
140 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
141 multiop_bg_pause $DIR/$tfile OS_c || return 1
143 #define OBD_FAIL_MDS_CLOSE_NET 0x115
145 echo "waiting for multiop $PID"
146 wait $PID || return 2
147 do_facet client munlink $DIR/$tfile || return 3
149 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
151 # Bug 113, check that readdir lost recv timeout works.
153 mkdir -p $DIR/$tdir || return 1
154 touch $DIR/$tdir/newentry || return
155 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
156 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
157 ls $DIR/$tdir || return 3
158 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
159 rm -rf $DIR/$tdir || return 4
161 run_test 13 "mdc_readpage restart test (bug 1138)"
163 # Bug 113, check that readdir lost send timeout works.
166 touch $DIR/$tdir/newentry
167 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
168 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
169 ls $DIR/$tdir || return 1
170 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
172 run_test 14 "mdc_readpage resend test (bug 1138)"
175 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
176 touch $DIR/$tfile && return 1
179 run_test 15 "failed open (-ENOMEM)"
181 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
183 lctl set_param -n llite.*.max_read_ahead_mb 0
187 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
191 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
193 do_facet client cp $SAMPLE_FILE $DIR
197 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
198 do_facet ost1 "lctl set_param fail_loc=0x80000504"
200 # OST bulk will time out here, client resends
201 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 1
202 do_facet ost1 lctl set_param fail_loc=0
203 # give recovery a chance to finish (shouldn't take long)
205 do_facet client "cmp $SAMPLE_FILE $DIR/${SAMPLE_FILE##*/}" || return 2
208 run_test 16 "timeout bulk put, don't evict client (2732)"
213 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
215 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
216 if at_is_enabled; then
217 at_max_saved=$(at_max_get ost1)
218 at_max_set $TIMEOUT ost1
221 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
222 # OST bulk will time out here, client retries
223 do_facet ost1 lctl set_param fail_loc=0x80000503
224 # need to ensure we send an RPC
225 do_facet client cp $SAMPLE_FILE $DIR/$tfile
228 # with AT, client will wait adaptive_max*factor+net_latency before
229 # expiring the req, hopefully timeout*2 is enough
230 sleep $(($TIMEOUT*2))
232 do_facet ost1 lctl set_param fail_loc=0
233 do_facet client "df $DIR"
234 # expect cmp to succeed, client resent bulk
235 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
236 do_facet client "rm $DIR/$tfile" || return 4
237 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
240 run_test 17 "timeout bulk get, don't evict client (2732)"
243 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
245 do_facet client mkdir -p $DIR/$tdir
249 pgcache_empty || return 1
252 $LFS setstripe -i 1 -c 1 $f
253 stripe_index=$($LFS getstripe -i $f)
254 if [ $stripe_index -ne 1 ]; then
256 error "$f: stripe_index $stripe_index != 1" && return
259 do_facet client cp $SAMPLE_FILE $f
261 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
262 $LCTL --device $osc2dev deactivate || return 3
263 # my understanding is that there should be nothing in the page
264 # cache after the client reconnects?
266 pgcache_empty || rc=2
267 $LCTL --device $osc2dev activate
271 run_test 18a "manual ost invalidate clears page cache immediately"
274 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
276 do_facet client mkdir -p $DIR/$tdir
280 pgcache_empty || return 1
282 $LFS setstripe -i 0 -c 1 $f
283 stripe_index=$($LFS getstripe -i $f)
284 if [ $stripe_index -ne 0 ]; then
286 error "$f: stripe_index $stripe_index != 0" && return
289 do_facet client cp $SAMPLE_FILE $f
292 # allow recovery to complete
293 sleep $((TIMEOUT + 2))
294 # my understanding is that there should be nothing in the page
295 # cache after the client reconnects?
297 pgcache_empty || rc=2
301 run_test 18b "eviction and reconnect clears page cache (2766)"
304 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
306 do_facet client mkdir -p $DIR/$tdir
310 pgcache_empty || return 1
312 $LFS setstripe -i 0 -c 1 $f
313 stripe_index=$($LFS getstripe -i $f)
314 if [ $stripe_index -ne 0 ]; then
316 error "$f: stripe_index $stripe_index != 0" && return
319 do_facet client cp $SAMPLE_FILE $f
323 # OBD_FAIL_OST_CONNECT_NET2
324 # lost reply to connect request
325 do_facet ost1 lctl set_param fail_loc=0x80000225
328 df $MOUNT > /dev/null 2>&1
330 # my understanding is that there should be nothing in the page
331 # cache after the client reconnects?
333 pgcache_empty || rc=2
337 run_test 18c "Dropped connect reply after eviction handing (14755)"
341 do_facet client mcreate $f || return 1
342 drop_ldlm_cancel "chmod 0777 $f" || echo "evicted as expected"
344 do_facet client checkstat -v -p 0777 $f || echo evicted
345 # let the client reconnect
347 do_facet client "munlink $f"
349 run_test 19a "test expired_lock_main on mds (2867)"
353 do_facet client $MULTIOP $f Ow || return 1
354 do_facet client $MULTIOP $f or || return 2
358 do_facet client $MULTIOP $f or || return 3
359 drop_ldlm_cancel $MULTIOP $f Ow || echo "client evicted, as expected"
361 do_facet client munlink $f || return 4
363 run_test 19b "test expired_lock_main on ost (2867)"
365 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
366 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
369 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
370 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
373 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
374 do_facet ost1 lctl set_param fail_loc=0x80000308
375 kill -USR1 $MULTI_PID
378 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
380 run_test 20a "ldlm_handle_enqueue error (should return error)"
382 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
383 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
386 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
388 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
389 do_facet ost1 lctl set_param fail_loc=0x80000308
390 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
391 error "didn't fail open enqueue" || true
393 run_test 20b "ldlm_handle_enqueue error (should return error)"
396 mkdir -p $DIR/$tdir-1
397 mkdir -p $DIR/$tdir-2
398 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
401 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
402 $MULTIOP $DIR/$tdir-2/f Oc &
405 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
407 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
408 kill -USR1 $close_pid
410 wait $close_pid || return 1
411 wait $open_pid || return 2
412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
414 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
415 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
419 run_test 21a "drop close request while close and open are both in flight"
422 mkdir -p $DIR/$tdir-1
423 mkdir -p $DIR/$tdir-2
424 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
427 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
428 mcreate $DIR/$tdir-2/f &
431 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
433 kill -USR1 $close_pid
435 wait $close_pid || return 1
436 wait $open_pid || return 3
438 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
439 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
442 run_test 21b "drop open request while close and open are both in flight"
445 mkdir -p $DIR/$tdir-1
446 mkdir -p $DIR/$tdir-2
447 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
450 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
451 mcreate $DIR/$tdir-2/f &
454 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
456 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
457 kill -USR1 $close_pid
459 wait $close_pid || return 1
460 wait $open_pid || return 2
462 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
464 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
465 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
468 run_test 21c "drop both request while close and open are both in flight"
471 mkdir -p $DIR/$tdir-1
472 mkdir -p $DIR/$tdir-2
473 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
476 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
477 $MULTIOP $DIR/$tdir-2/f Oc &
479 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
481 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
484 wait $pid || return 1
485 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
487 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
488 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
492 run_test 21d "drop close reply while close and open are both in flight"
495 mkdir -p $DIR/$tdir-1
496 mkdir -p $DIR/$tdir-2
497 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
500 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
501 touch $DIR/$tdir-2/f &
503 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
507 wait $pid || return 1
510 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
511 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
514 run_test 21e "drop open reply while close and open are both in flight"
517 mkdir -p $DIR/$tdir-1
518 mkdir -p $DIR/$tdir-2
519 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
523 touch $DIR/$tdir-2/f &
525 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
527 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
530 wait $pid || return 1
531 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
533 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
534 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
537 run_test 21f "drop both reply while close and open are both in flight"
540 mkdir -p $DIR/$tdir-1
541 mkdir -p $DIR/$tdir-2
542 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
545 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
546 touch $DIR/$tdir-2/f &
548 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
550 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
553 wait $pid || return 1
554 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
556 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
557 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
560 run_test 21g "drop open reply and close request while close and open are both in flight"
563 mkdir -p $DIR/$tdir-1
564 mkdir -p $DIR/$tdir-2
565 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
568 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
569 touch $DIR/$tdir-2/f &
572 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
574 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
577 wait $pid || return 1
578 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
580 wait $touch_pid || return 2
582 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
583 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
586 run_test 21h "drop open request and close reply while close and open are both in flight"
588 # bug 3462 - multiple MDC requests
593 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
598 $MULTIOP $f1 msu || return 1
601 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
603 wait $close_pid || return 2
604 rm -rf $f2 || return 4
606 run_test 22 "drop close request and do mknod"
609 multiop_bg_pause $DIR/$tfile O_c || return 1
611 # give a chance for open
615 drop_request "kill -USR1 $pid"
618 wait $pid || return 1
621 run_test 23 "client hang when close a file after mds crash"
623 test_24() { # bug 11710 details correct fsync() behavior
624 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
627 $LFS setstripe -i 0 -c 1 $DIR/$tdir
629 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
632 kill -USR1 $MULTI_PID
635 lctl set_param fail_loc=0x0
637 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
639 run_test 24 "fsync error (should return error)"
641 wait_client_evicted () {
644 local varsvc=${facet}_svc
646 wait_update $(facet_active_host $facet) \
647 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
651 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
652 # this test can only run from a client on a separate node.
653 remote_ost || { skip "local OST" && return 0; }
654 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
655 remote_mds || { skip "local MDS" && return 0; }
657 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
658 skip "msg and ost1 are at the same node"
662 check_timeout || return 1
664 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
666 echo starting with $OST_NEXP OST exports
667 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
668 do_facet client lctl set_param fail_loc=0x505
669 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
670 # But if there's a race to start the evictor from various obds,
671 # the loser might have to wait for the next ping.
674 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
676 do_facet client lctl set_param fail_loc=0x0
677 [ $rc -eq 0 ] || error "client not evicted from OST"
679 run_test 26a "evict dead exports"
681 test_26b() { # bug 10140 - evict dead exports by pinger
682 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
684 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
685 skip "msg and ost1 are at the same node"
689 check_timeout || return 1
691 zconf_mount `hostname` $MOUNT2 ||
692 { error "Failed to mount $MOUNT2"; return 2; }
693 sleep 1 # wait connections being established
695 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
696 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
698 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
700 zconf_umount `hostname` $MOUNT2 -f
702 # PING_INTERVAL max(obd_timeout / 4, 1U)
703 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
705 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
706 # But if there's a race to start the evictor from various obds,
707 # the loser might have to wait for the next ping.
708 # = 9 * PING_INTERVAL + PING_INTERVAL
709 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
710 # let's wait $((TIMEOUT * 3)) # bug 19887
712 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
713 error "Client was not evicted by ost" rc=1
714 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
715 error "Client was not evicted by mds"
717 run_test 26b "evict dead exports"
721 writemany -q -a $DIR/$tdir/$tfile 0 5 &
724 local save_FAILURE_MODE=$FAILURE_MODE
726 facet_failover $SINGLEMDS
727 #define OBD_FAIL_OSC_SHUTDOWN 0x407
728 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
729 # need to wait for reconnect
730 echo waiting for fail_loc
731 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
732 facet_failover $SINGLEMDS
734 kill -USR1 $CLIENT_PID
737 FAILURE_MODE=$save_FAILURE_MODE
739 run_test 27 "fail LOV while using OSC's"
741 test_28() { # bug 6086 - error adding new clients
742 do_facet client mcreate $DIR/$tfile || return 1
743 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
744 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
745 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
746 # fail once (evicted), reconnect fail (fail_loc), ok
747 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
749 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
751 run_test 28 "handle error adding new clients (bug 6086)"
753 test_29a() { # bug 22273 - error adding new clients
754 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
755 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
756 # fail abort so client will be new again
757 fail_abort $SINGLEMDS
758 client_up || error "reconnect failed"
761 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
763 test_29b() { # bug 22273 - error adding new clients
764 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
765 do_facet ost1 "lctl set_param fail_loc=0x80000711"
766 # fail abort so client will be new again
768 client_up || error "reconnect failed"
771 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
775 # put a load of file creates/writes/deletes
776 writemany -q $DIR/$tdir/$tfile 0 5 &
778 echo writemany pid $CLIENT_PID
782 # wait for client to reconnect to MDS
787 # client process should see no problems even though MDS went down
789 kill -USR1 $CLIENT_PID
792 echo writemany returned $rc
793 #these may fail because of eviction due to slow AST response.
794 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
796 run_test 50 "failover MDS under load"
799 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
800 do_facet ost1 lctl set_param fail_loc=0x00001310
803 # put a load of file creates/writes/deletes
804 writemany -q $DIR/$tdir/$tfile 0 5 &
808 facet_failover $SINGLEMDS
809 # failover at various points during recovery
810 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
811 echo will failover at $SEQ
814 echo failover in $i sec
816 facet_failover $SINGLEMDS
818 # client process should see no problems even though MDS went down
819 # and recovery was interrupted
821 kill -USR1 $CLIENT_PID
824 echo writemany returned $rc
825 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
827 run_test 51 "failover MDS during recovery"
830 do_facet client "mkdir -p $DIR/$tdir"
831 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
833 echo writemany pid $CLIENT_PID
838 wait $CLIENT_PID || rc=$?
839 # active client process should see an EIO for down OST
840 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
841 # but timing or failover setup may allow success
842 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
843 echo "writemany returned $rc"
848 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
853 [ $rc -ne 0 ] && { return $rc; }
854 # wait for client to reconnect to OST
858 [ $rc -ne 0 ] && { return $rc; }
865 run_test 52 "failover OST under load"
867 # test of open reconstruct
870 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
873 run_test 53 "touch: drop rep"
876 zconf_mount `hostname` $MOUNT2
880 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
883 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
884 [ x"$ERROR" == x ] || error "back in time occured"
886 run_test 54 "back in time"
888 # bug 11330 - liblustre application death during I/O locks up OST
890 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
894 # first dd should be finished quickly
895 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
896 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
899 echo "step1: testing ......"
901 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
903 if [ $count -gt 64 ]; then
904 error "dd should be finished!"
908 echo "(dd_pid=$DDPID, time=$count)successful"
910 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
911 #define OBD_FAIL_OST_DROP_REQ 0x21d
912 do_facet ost1 lctl set_param fail_loc=0x0000021d
913 # second dd will be never finished
914 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
917 echo "step2: testing ......"
918 while [ $count -le 64 ]; do
919 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
920 if [ -z $dd_name ]; then
922 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
923 error "dd shouldn't be finished!"
928 echo "(dd_pid=$DDPID, time=$count)successful"
930 #Recover fail_loc and dd will finish soon
931 do_facet ost1 lctl set_param fail_loc=0
933 echo "step3: testing ......"
935 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
937 if [ $count -gt 500 ]; then
938 error "dd should be finished!"
942 echo "(dd_pid=$DDPID, time=$count)successful"
946 run_test 55 "ost_brw_read/write drops timed-out read/write request"
948 test_56() { # b=11277
949 #define OBD_FAIL_MDS_RESEND 0x136
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
953 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
956 run_test 56 "do not allow reconnect to busy exports"
959 # no oscs means no client or mdt
960 while lctl get_param osc.*.* > /dev/null 2>&1; do
961 : # loop until proc file is removed
965 test_57() { # bug 10866
969 #define OBD_FAIL_LPROC_REMOVE 0xB00
970 lctl set_param fail_loc=0x80000B00
971 zconf_umount `hostname` $DIR
972 lctl set_param fail_loc=0x80000B00
973 fail_abort $SINGLEMDS
975 lctl set_param fail_loc=0
977 do_facet client "df $DIR"
979 run_test 57 "read procfs entries causes kernel crash"
981 test_58() { # bug 11546
982 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
985 lctl set_param fail_loc=0x80000801
986 cp $DIR/$tfile /dev/null &
989 lctl set_param fail_loc=0
990 drop_bl_callback rm -f $DIR/$tfile
992 do_facet client "df $DIR"
994 run_test 58 "Eviction in the middle of open RPC reply processing"
996 test_59() { # bug 10589
997 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
998 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
999 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1000 lctl set_param fail_loc=0x311
1001 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1002 [ $? = 0 ] || error "dd write failed"
1003 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1004 lctl set_param fail_loc=0
1006 zconf_umount `hostname` $MOUNT2 -f
1007 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1008 [ $? = 0 ] || error "dd read failed"
1009 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1010 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1012 run_test 59 "Read cancel race on client eviction"
1015 # we assume that all md changes are in the MDT0 changelog
1016 if [ $MDSCOUNT -gt 1 ]; then
1017 error_ignore 17935 $*
1024 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
1025 awk '{gsub(/_UUID/,""); print $1}' | head -1)
1030 # Register (and start) changelog
1031 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1032 echo "Registered as $MDT0 changelog user $USER"
1034 # Generate a large number of changelog entries
1035 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1039 # Unlink files in the background
1040 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1044 # Failover the MDS while unlinks are happening
1045 facet_failover $SINGLEMDS
1047 # Wait for unlinkmany to finish
1050 # Check if all the create/unlink events were recorded
1052 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1053 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1054 echo "$cl_count unlinks in $MDT0 changelog"
1056 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1057 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1058 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1059 if [ $USERS -eq 0 ]; then
1060 [ $cl_count -eq $NUM_FILES ] || \
1061 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1062 # Also make sure we can clear large changelogs
1063 cl_count=$($LFS changelog $FSNAME | wc -l)
1064 [ $cl_count -le 2 ] || \
1065 error "Changelog not empty: $cl_count entries"
1067 # If there are other users, there may be other unlinks in the log
1068 [ $cl_count -ge $NUM_FILES ] || \
1069 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1070 echo "$USERS other changelog users; can't verify clear"
1073 run_test 60 "Add Changelog entries during MDS failover"
1077 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1078 mdtosc=${mdtosc/-MDT*/-MDT\*}
1079 local cflags="osc.$mdtosc.connect_flags"
1080 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1081 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1083 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1084 # Set the default stripe of $DIR/$tdir to put the files to ost1
1085 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1087 replay_barrier $SINGLEMDS
1088 createmany -o $DIR/$tdir/$tfile-%d 10
1089 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1091 fail_abort $SINGLEMDS
1093 touch $DIR/$tdir/$tfile
1094 local id=`$LFS getstripe $DIR/$tdir/$tfile | awk '$1 == 0 { print $2 }'`
1095 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1100 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1102 check_cli_ir_state()
1104 local NODE=${1:-$HOSTNAME}
1106 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1107 awk '/imperative_recovery:/ { print \\\$2}'")
1108 [ $st != ON -o $st != OFF ] ||
1109 error "Error state $st, must be ON or OFF"
1113 check_target_ir_state()
1116 local name=${target}_svc
1117 local recovery_proc=obdfilter.${!name}.recovery_status
1120 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1121 awk '/IR:/{ print \\\$2}'")
1122 [ $st != ON -o $st != OFF ] ||
1123 error "Error state $st, must be ON or OFF"
1129 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1134 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1135 awk '/state:/{ print \\\$2 }'")
1139 nidtbl_version_mgs()
1141 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1142 awk '/nidtbl_version:/{ print \\\$2 }'")
1146 # nidtbl_version_client <mds1|client> [node]
1147 nidtbl_version_client()
1150 local node=${2:-$HOSTNAME}
1152 if [ X$cli = Xclient ]; then
1155 local obdtype=${cli/%[0-9]*/}
1156 [ $obdtype != mds ] && error "wrong parameters $cli"
1158 node=$(facet_active_host $cli)
1163 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1164 awk "/$cli/{print \$6}" |sort -u)
1166 # in case there are multiple mounts on the client node
1168 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1172 nidtbl_versions_match()
1174 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1177 target_instance_match()
1183 obdtype=${srv/%[0-9]*/}
1194 error "invalid target type" $srv
1199 local target=${srv}_svc
1200 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1201 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
1202 awk '/instance/{ print $2 }' |head -1)
1204 return $([ $si -eq $ci ])
1209 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1210 { skip "MGS without IR support"; return 0; }
1213 set_ir_status disabled
1215 local saved_FAILURE_MODE=$FAILURE_MODE
1216 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1220 nidtbl_versions_match &&
1221 error "version must differ due to IR disabled"
1222 target_instance_match ost1 || error "instance mismatch"
1226 FAILURE_MODE=$saved_FAILURE_MODE
1228 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1232 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1233 { skip "MGS without IR support"; return 0; }
1237 local OST1_IMP=$(get_osc_import_name client ost1)
1239 # disable pinger recovery
1240 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1244 target_instance_match ost1 || error "instance mismatch"
1245 nidtbl_versions_match || error "version must match"
1247 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1249 run_test 101 "IR: Make sure IR works w/o normal recovery"
1253 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1254 { skip "MGS without IR support"; return 0; }
1256 local clients=${CLIENTS:-$HOSTNAME}
1263 # let's have a new nidtbl version
1266 # sleep for a while so that clients can see the failure of ost
1267 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1268 # int mgc_request.c:
1269 # define MGC_TIMEOUT_MIN_SECONDS 5
1270 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1271 local count=30 # 20 seconds at most
1272 while [ $count -gt 0 ]; do
1273 nidtbl_versions_match && break
1278 nidtbl_versions_match || error "nidtbl mismatch"
1281 old_version=$(nidtbl_version_client client)
1283 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1286 combined_mgs_mds && mgsdev=mds1
1287 remount_facet $mgsdev
1290 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1293 new_version=$(nidtbl_version_client client)
1294 [ $new_version -lt $old_version ] &&
1295 error "nidtbl version wrong after mgs restarts"
1298 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1302 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1303 { skip "MGS without IR support"; return 0; }
1305 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1307 # workaround solution to generate config log on the mds
1313 # We need this test because mds is like a client in IR context.
1314 start mds1 $MDSDEV1 || error "MDS should start w/o mgs"
1316 # start mgs and remount mds w/ ir
1320 # remount client so that fsdb will be created on the MGS
1321 umount_client $MOUNT || error "umount failed"
1322 mount_client $MOUNT || error "mount failed"
1324 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1326 while [ $count -gt 0 ]; do
1327 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1332 # after a while, mds should be able to reconnect to mgs and fetch
1333 # up-to-date nidtbl version
1334 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1339 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1343 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1344 { skip "MGS without IR support"; return 0; }
1349 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1350 error "OST1 cannot start"
1353 local ir_state=$(check_target_ir_state ost1)
1354 [ $ir_state = "OFF" ] || error "ir status on ost1 should be OFF"
1356 run_test 104 "IR: ost can disable IR voluntarily"
1360 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1361 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1362 { skip "MGS without IR support"; return 0; }
1366 # get one of the clients from client list
1367 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1369 local old_MOUNTOPT=$MOUNTOPT
1370 MOUNTOPT=${MOUNTOPT},noir
1371 zconf_umount $rcli $MOUNT || error "umount failed"
1372 zconf_mount $rcli $MOUNT || error "mount failed"
1374 # make sure lustre mount at $rcli disabling IR
1375 local ir_state=$(check_cli_ir_state $rcli)
1376 [ $ir_state = OFF ] || error "IR state must be OFF at $rcli"
1378 # make sure MGS's state is Partial
1379 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1382 # make sure IR on ost1 is OFF
1383 local ir_state=$(check_target_ir_state ost1)
1384 [ $ir_state = "OFF" ] || error "IR status on ost1 should be OFF"
1387 MOUNTOPT=$old_MOUNTOPT
1388 zconf_umount $rcli $MOUNT || error "umount failed"
1389 zconf_mount $rcli $MOUNT || error "mount failed"
1391 # make sure MGS's state is full
1392 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1395 # make sure IR on ost1 is ON
1396 local ir_state=$(check_target_ir_state ost1)
1397 [ $ir_state = "ON" ] || error "IR status on ost1 should be OFF"
1401 run_test 105 "IR: NON IR clients support"
1403 complete $(basename $0) $SECONDS
1404 check_and_cleanup_lustre