6 ALWAYS_EXCEPT="52 60 $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"
22 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
23 # bug number for skipped test: LU-2194
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 19b"
28 # Allow us to override the setup if we already have a mounted system by
29 # setting SETUP=" " and CLEANUP=" "
31 CLEANUP=${CLEANUP:-""}
33 check_and_setup_lustre
36 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
39 local f1="$DIR/$tfile"
40 local f2="$DIR/$tfile.2"
42 drop_request "mcreate $f1" ||
43 error_noexit "create '$f1': drop req"
45 drop_reint_reply "mcreate $f2" ||
46 error_noexit "create '$f2': drop rep"
48 drop_request "tchmod 111 $f2" ||
49 error_noexit "chmod '$f2': drop req"
51 drop_reint_reply "tchmod 666 $f2" ||
52 error_noexit "chmod '$f2': drop rep"
54 drop_request "statone $f2" ||
55 error_noexit "stat '$f2': drop req"
57 drop_reply "statone $f2" ||
58 error_noexit "stat '$f2': drop rep"
60 run_test 1 "create, chmod, stat: drop req, drop rep"
64 do_facet_create_file client $t 10K ||
65 error_noexit "Create file $t"
67 drop_request "cat $t > /dev/null" ||
68 error_noexit "Open request for $t file"
70 drop_reply "cat $t > /dev/null" ||
71 error_noexit "Open replay for $t file"
73 run_test 4 "open: drop req, drop rep"
78 local RR="$T-renamed-again"
79 do_facet_create_file client $T 10K ||
80 error_noexit "Create file $T"
82 drop_request "mv $T $R" ||
83 error_noexit "Rename $T"
85 drop_reint_reply "mv $R $RR" ||
86 error_noexit "Failed rename replay on $R"
88 do_facet client "checkstat -v $RR" ||
89 error_noexit "checkstat error on $RR"
91 do_facet client "rm $RR" ||
92 error_noexit "Can't remove file $RR"
94 run_test 5 "rename: drop req, drop rep"
98 local LINK1=$DIR/$tfile.link1
99 local LINK2=$DIR/$tfile.link2
101 do_facet_create_file client $T 10K ||
102 error_noexit "Create file $T"
104 drop_request "mlink $T $LINK1" ||
105 error_noexit "mlink request for $T"
107 drop_reint_reply "mlink $T $LINK2" ||
108 error_noexit "mlink reply for $T"
110 drop_request "munlink $LINK1" ||
111 error_noexit "munlink request for $T"
113 drop_reint_reply "munlink $LINK2" ||
114 error_noexit "munlink reply for $T"
116 do_facet client "rm $T" ||
117 error_noexit "Can't remove file $T"
119 run_test 6 "link, unlink: drop req, drop rep"
123 drop_reint_reply "touch $DIR/$tfile" || return 1
125 run_test 8 "touch: drop rep (bug 1423)"
129 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
133 do_facet_random_file client $TMP/$tfile 1K ||
134 error_noexit "Create random file $TMP/$tfile"
135 # make this big, else test 9 doesn't wait for bulk -- bz 5595
136 do_facet_create_file client $TMP/$t1 4M ||
137 error_noexit "Create file $TMP/$t1"
138 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
139 error_noexit "Can't copy to $DIR/$t1 file"
140 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
141 error_noexit "Can't pause_bulk copy"
142 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
143 error_noexit "Can't copy file"
144 do_facet client "sync"
145 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
146 error_noexit "Can't remove files"
147 do_facet client "rm $TMP/$t1 $TMP/$tfile"
149 run_test 9 "pause bulk on OST (bug 1420)"
153 do_facet client mcreate $DIR/$tfile ||
154 { error "mcreate failed: $?"; return 1; }
155 drop_bl_callback "chmod 0777 $DIR/$tfile" || echo "evicted as expected"
156 # wait for the mds to evict the client
157 #echo "sleep $(($TIMEOUT*2))"
158 #sleep $(($TIMEOUT*2))
159 do_facet client touch $DIR/$tfile || echo "touch failed, evicted"
160 do_facet client checkstat -v -p 0777 $DIR/$tfile ||
161 { error "client checkstat failed: $?"; return 3; }
162 do_facet client "munlink $DIR/$tfile"
163 # allow recovery to complete
164 client_up || client_up || sleep $TIMEOUT
166 run_test 10 "finish request on server after client eviction (bug 1521)"
169 # wake up a thread waiting for completion after eviction
171 do_facet client $MULTIOP $DIR/$tfile Ow ||
172 { error "multiop write failed: $?"; return 1; }
173 do_facet client $MULTIOP $DIR/$tfile or ||
174 { error "multiop read failed: $?"; return 2; }
178 do_facet client $MULTIOP $DIR/$tfile or ||
179 { error "multiop read failed: $?"; return 3; }
180 drop_bl_callback $MULTIOP $DIR/$tfile Ow || echo "evicted as expected"
182 do_facet client munlink $DIR/$tfile ||
183 { error "munlink failed: $?"; return 4; }
184 # allow recovery to complete
185 client_up || client_up || sleep $TIMEOUT
187 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
191 $LCTL mark $MULTIOP $DIR/$tfile OS_c
192 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
193 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
194 multiop_bg_pause $DIR/$tfile OS_c ||
195 { error "multiop failed: $?"; return 1; }
197 #define OBD_FAIL_MDS_CLOSE_NET 0x115
199 echo "waiting for multiop $PID"
200 wait $PID || { error "wait for multiop faile: $?"; return 2; }
201 do_facet client munlink $DIR/$tfile ||
202 { error "client munlink failed: $?"; return 3; }
203 # allow recovery to complete
204 client_up || client_up || sleep $TIMEOUT
206 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
208 # Bug 113, check that readdir lost recv timeout works.
210 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
211 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
212 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
213 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
214 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
215 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
216 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
218 run_test 13 "mdc_readpage restart test (bug 1138)"
220 # Bug 113, check that readdir lost send timeout works.
223 touch $DIR/$tdir/newentry
224 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
225 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
226 ls $DIR/$tdir || return 1
227 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
229 run_test 14 "mdc_readpage resend test (bug 1138)"
232 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
233 touch $DIR/$tfile && return 1
236 run_test 15 "failed open (-ENOMEM)"
238 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
240 lctl set_param -n llite.*.max_read_ahead_mb 0
244 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
248 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
250 do_facet_random_file client $TMP/$tfile 100K ||
251 { error_noexit "Create random file $TMP/$T" ; return 0; }
252 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
253 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
257 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
258 do_facet ost1 "lctl set_param fail_loc=0x80000504"
260 # OST bulk will time out here, client resends
261 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
262 do_facet ost1 lctl set_param fail_loc=0
263 # give recovery a chance to finish (shouldn't take long)
265 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
268 run_test 16 "timeout bulk put, don't evict client (2732)"
273 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
275 local SAMPLE_FILE=$TMP/$tfile
276 do_facet_random_file client $SAMPLE_FILE 20K ||
277 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
279 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
280 if at_is_enabled; then
281 at_max_saved=$(at_max_get ost1)
282 at_max_set $TIMEOUT ost1
285 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
286 # OST bulk will time out here, client retries
287 do_facet ost1 lctl set_param fail_loc=0x80000503
288 # need to ensure we send an RPC
289 do_facet client cp $SAMPLE_FILE $DIR/$tfile
292 # with AT, client will wait adaptive_max*factor+net_latency before
293 # expiring the req, hopefully timeout*2 is enough
294 sleep $(($TIMEOUT*2))
296 do_facet ost1 lctl set_param fail_loc=0
297 do_facet client "df $DIR"
298 # expect cmp to succeed, client resent bulk
299 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
300 do_facet client "rm $DIR/$tfile" || return 4
301 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
304 run_test 17 "timeout bulk get, don't evict client (2732)"
307 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
309 do_facet_create_file client $TMP/$tfile 20K ||
310 { error_noexit "Create file $TMP/$tfile" ; return 0; }
312 do_facet client mkdir -p $DIR/$tdir
316 pgcache_empty || return 1
319 $LFS setstripe -i 1 -c 1 $f
320 stripe_index=$($LFS getstripe -i $f)
321 if [ $stripe_index -ne 1 ]; then
323 error "$f: stripe_index $stripe_index != 1" && return
326 do_facet client cp $TMP/$tfile $f
328 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
329 $LCTL --device $osc2dev deactivate || return 3
330 # my understanding is that there should be nothing in the page
331 # cache after the client reconnects?
333 pgcache_empty || rc=2
334 $LCTL --device $osc2dev activate
338 run_test 18a "manual ost invalidate clears page cache immediately"
341 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
343 do_facet_create_file client $TMP/$tfile 20K ||
344 { error_noexit "Create file $TMP/$tfile" ; return 0; }
346 do_facet client mkdir -p $DIR/$tdir
350 pgcache_empty || return 1
352 $LFS setstripe -i 0 -c 1 $f
353 stripe_index=$($LFS getstripe -i $f)
354 if [ $stripe_index -ne 0 ]; then
356 error "$f: stripe_index $stripe_index != 0" && return
359 do_facet client cp $TMP/$tfile $f
362 # allow recovery to complete
363 sleep $((TIMEOUT + 2))
364 # my understanding is that there should be nothing in the page
365 # cache after the client reconnects?
367 pgcache_empty || rc=2
371 run_test 18b "eviction and reconnect clears page cache (2766)"
374 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
376 do_facet_create_file client $TMP/$tfile 20K ||
377 { error_noexit "Create file $TMP/$tfile" ; return 0; }
379 do_facet client mkdir -p $DIR/$tdir
383 pgcache_empty || return 1
385 $LFS setstripe -i 0 -c 1 $f
386 stripe_index=$($LFS getstripe -i $f)
387 if [ $stripe_index -ne 0 ]; then
389 error "$f: stripe_index $stripe_index != 0" && return
392 do_facet client cp $TMP/$tfile $f
396 # OBD_FAIL_OST_CONNECT_NET2
397 # lost reply to connect request
398 do_facet ost1 lctl set_param fail_loc=0x80000225
401 df $MOUNT > /dev/null 2>&1
403 # my understanding is that there should be nothing in the page
404 # cache after the client reconnects?
406 pgcache_empty || rc=2
410 run_test 18c "Dropped connect reply after eviction handing (14755)"
413 local BEFORE=`date +%s`
416 mount_client $DIR2 || error "failed to mount $DIR2"
418 # cancel cached locks from OST to avoid eviction from it
421 do_facet client "stat $DIR > /dev/null" ||
422 error "failed to stat $DIR: $?"
423 drop_ldlm_cancel "chmod 0777 $DIR2" ||
424 error "failed to chmod $DIR2"
428 # let the client reconnect
430 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state | \
431 awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
433 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
434 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
435 error "no eviction: $EVICT before:$BEFORE")
437 run_test 19a "test expired_lock_main on mds (2867)"
440 local BEFORE=`date +%s`
443 mount_client $DIR2 || error "failed to mount $DIR2: $?"
445 # cancel cached locks from MDT to avoid eviction from it
448 do_facet client $MULTIOP $DIR/$tfile Ow ||
449 error "failed to run multiop: $?"
450 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
451 error "failed to ldlm_cancel: $?"
453 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
454 do_facet client munlink $DIR/$tfile ||
455 error "failed to unlink $DIR/$tfile: $?"
457 # let the client reconnect
459 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state | \
460 awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
462 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
463 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
464 error "no eviction: $EVICT before:$BEFORE")
466 run_test 19b "test expired_lock_main on ost (2867)"
469 local BEFORE=`date +%s`
472 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
474 mkdir -p $DIR1/$tfile
477 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
478 do_facet mds $LCTL set_param fail_loc=0x80000516
480 touch $DIR2/$tfile/file1 &
482 # let touch to get blocked on the server
486 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
489 # let the client reconnect
491 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
492 awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
494 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
496 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
498 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
499 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
502 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
503 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
506 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
507 do_facet ost1 lctl set_param fail_loc=0x80000308
508 kill -USR1 $MULTI_PID
511 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
513 run_test 20a "ldlm_handle_enqueue error (should return error)"
515 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
516 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
519 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
521 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
522 do_facet ost1 lctl set_param fail_loc=0x80000308
523 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
524 error "didn't fail open enqueue" || true
526 run_test 20b "ldlm_handle_enqueue error (should return error)"
529 mkdir -p $DIR/$tdir-1
530 mkdir -p $DIR/$tdir-2
531 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
534 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
535 $MULTIOP $DIR/$tdir-2/f Oc &
538 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
540 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
541 kill -USR1 $close_pid
543 wait $close_pid || return 1
544 wait $open_pid || return 2
545 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
547 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
548 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
552 run_test 21a "drop close request while close and open are both in flight"
555 mkdir -p $DIR/$tdir-1
556 mkdir -p $DIR/$tdir-2
557 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
560 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
561 mcreate $DIR/$tdir-2/f &
564 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
566 kill -USR1 $close_pid
568 wait $close_pid || return 1
569 wait $open_pid || return 3
571 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
572 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
575 run_test 21b "drop open request while close and open are both in flight"
578 mkdir -p $DIR/$tdir-1
579 mkdir -p $DIR/$tdir-2
580 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
583 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
584 mcreate $DIR/$tdir-2/f &
587 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
589 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
590 kill -USR1 $close_pid
592 wait $close_pid || return 1
593 wait $open_pid || return 2
595 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
597 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
598 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
601 run_test 21c "drop both request while close and open are both in flight"
604 mkdir -p $DIR/$tdir-1
605 mkdir -p $DIR/$tdir-2
606 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
609 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
610 $MULTIOP $DIR/$tdir-2/f Oc &
612 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
614 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
617 wait $pid || return 1
618 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
620 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
621 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
625 run_test 21d "drop close reply while close and open are both in flight"
628 mkdir -p $DIR/$tdir-1
629 mkdir -p $DIR/$tdir-2
630 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
633 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
634 touch $DIR/$tdir-2/f &
636 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
640 wait $pid || return 1
643 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
644 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
647 run_test 21e "drop open reply while close and open are both in flight"
650 mkdir -p $DIR/$tdir-1
651 mkdir -p $DIR/$tdir-2
652 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
655 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
656 touch $DIR/$tdir-2/f &
658 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
660 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
663 wait $pid || return 1
664 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
666 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
667 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
670 run_test 21f "drop both reply while close and open are both in flight"
673 mkdir -p $DIR/$tdir-1
674 mkdir -p $DIR/$tdir-2
675 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
678 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
679 touch $DIR/$tdir-2/f &
681 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
683 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
686 wait $pid || return 1
687 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
689 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
690 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
693 run_test 21g "drop open reply and close request while close and open are both in flight"
696 mkdir -p $DIR/$tdir-1
697 mkdir -p $DIR/$tdir-2
698 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
701 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
702 touch $DIR/$tdir-2/f &
705 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
707 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
710 wait $pid || return 1
711 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
713 wait $touch_pid || return 2
715 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
716 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
719 run_test 21h "drop open request and close reply while close and open are both in flight"
721 # bug 3462 - multiple MDC requests
726 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
731 $MULTIOP $f1 msu || return 1
734 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
736 wait $close_pid || return 2
737 rm -rf $f2 || return 4
739 run_test 22 "drop close request and do mknod"
742 multiop_bg_pause $DIR/$tfile O_c || return 1
744 # give a chance for open
748 drop_request "kill -USR1 $pid"
751 wait $pid || return 1
754 run_test 23 "client hang when close a file after mds crash"
756 test_24a() { # bug 11710 details correct fsync() behavior
757 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
760 $LFS setstripe -i 0 -c 1 $DIR/$tdir
762 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
765 kill -USR1 $MULTI_PID
768 lctl set_param fail_loc=0x0
770 [ $rc -eq 0 ] && error_ignore 5494 "multiop didn't fail fsync: rc $rc" || true
772 run_test 24a "fsync error (should return error)"
774 wait_client_evicted () {
777 local varsvc=${facet}_svc
779 wait_update $(facet_active_host $facet) \
780 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
785 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
789 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
791 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
792 error "mulitop Ow8192_yc failed"
795 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
796 error "mulitop Ow8192_c failed"
801 kill -USR1 $MULTI_PID1
804 kill -USR1 $MULTI_PID2
807 lctl set_param fail_loc=0x0
809 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
810 error_ignore 5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
813 dmesg | grep "dirty page discard:" || \
814 error "no discarded dirty page found!"
816 run_test 24b "test dirty page discard due to client eviction"
818 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
819 # this test can only run from a client on a separate node.
820 remote_ost || { skip "local OST" && return 0; }
821 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
822 remote_mds || { skip "local MDS" && return 0; }
824 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
825 skip "msg and ost1 are at the same node"
829 check_timeout || return 1
831 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
833 echo starting with $OST_NEXP OST exports
834 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
835 do_facet client lctl set_param fail_loc=0x505
836 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
837 # But if there's a race to start the evictor from various obds,
838 # the loser might have to wait for the next ping.
841 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
843 do_facet client lctl set_param fail_loc=0x0
844 [ $rc -eq 0 ] || error "client not evicted from OST"
846 run_test 26a "evict dead exports"
848 test_26b() { # bug 10140 - evict dead exports by pinger
849 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
851 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
852 skip "msg and ost1 are at the same node"
856 check_timeout || return 1
858 zconf_mount `hostname` $MOUNT2 ||
859 { error "Failed to mount $MOUNT2"; return 2; }
860 sleep 1 # wait connections being established
862 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
863 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
865 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
867 zconf_umount `hostname` $MOUNT2 -f
869 # PING_INTERVAL max(obd_timeout / 4, 1U)
870 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
872 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
873 # But if there's a race to start the evictor from various obds,
874 # the loser might have to wait for the next ping.
875 # = 9 * PING_INTERVAL + PING_INTERVAL
876 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
877 # let's wait $((TIMEOUT * 3)) # bug 19887
879 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
880 error "Client was not evicted by ost" rc=1
881 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
882 error "Client was not evicted by mds"
884 run_test 26b "evict dead exports"
888 writemany -q -a $DIR/$tdir/$tfile 0 5 &
891 local save_FAILURE_MODE=$FAILURE_MODE
893 facet_failover $SINGLEMDS
894 #define OBD_FAIL_OSC_SHUTDOWN 0x407
895 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
896 # need to wait for reconnect
897 echo waiting for fail_loc
898 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
899 facet_failover $SINGLEMDS
901 kill -USR1 $CLIENT_PID
904 FAILURE_MODE=$save_FAILURE_MODE
906 run_test 27 "fail LOV while using OSC's"
908 test_28() { # bug 6086 - error adding new clients
909 do_facet client mcreate $DIR/$tfile || return 1
910 drop_bl_callback "chmod 0777 $DIR/$tfile" ||echo "evicted as expected"
911 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
912 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
913 # fail once (evicted), reconnect fail (fail_loc), ok
914 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
916 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
918 run_test 28 "handle error adding new clients (bug 6086)"
920 test_29a() { # bug 22273 - error adding new clients
921 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
922 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
923 # fail abort so client will be new again
924 fail_abort $SINGLEMDS
925 client_up || error "reconnect failed"
926 wait_osc_import_state mds ost FULL
929 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
931 test_29b() { # bug 22273 - error adding new clients
932 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
933 do_facet ost1 "lctl set_param fail_loc=0x80000711"
934 # fail abort so client will be new again
936 client_up || error "reconnect failed"
939 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
943 # put a load of file creates/writes/deletes
944 writemany -q $DIR/$tdir/$tfile 0 5 &
946 echo writemany pid $CLIENT_PID
950 # wait for client to reconnect to MDS
955 # client process should see no problems even though MDS went down
957 kill -USR1 $CLIENT_PID
960 echo writemany returned $rc
961 #these may fail because of eviction due to slow AST response.
962 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
964 run_test 50 "failover MDS under load"
967 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
968 do_facet ost1 lctl set_param fail_loc=0x00001310
971 # put a load of file creates/writes/deletes
972 writemany -q $DIR/$tdir/$tfile 0 5 &
976 facet_failover $SINGLEMDS
977 # failover at various points during recovery
978 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
979 echo will failover at $SEQ
982 #echo failover in $i sec
983 log "test_$testnum: failover in $i sec"
985 facet_failover $SINGLEMDS
987 # client process should see no problems even though MDS went down
988 # and recovery was interrupted
990 kill -USR1 $CLIENT_PID
993 echo writemany returned $rc
994 [ $rc -eq 0 ] || error_ignore 13652 "writemany returned rc $rc" || true
996 run_test 51 "failover MDS during recovery"
999 do_facet client "mkdir -p $DIR/$tdir"
1000 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1002 echo writemany pid $CLIENT_PID
1007 wait $CLIENT_PID || rc=$?
1008 # active client process should see an EIO for down OST
1009 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1010 # but timing or failover setup may allow success
1011 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1012 echo "writemany returned $rc"
1017 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1022 [ $rc -ne 0 ] && { return $rc; }
1023 # wait for client to reconnect to OST
1027 [ $rc -ne 0 ] && { return $rc; }
1034 run_test 52 "failover OST under load"
1036 # test of open reconstruct
1039 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1042 run_test 53 "touch: drop rep"
1045 zconf_mount `hostname` $MOUNT2
1047 touch $DIR2/$tfile.1
1049 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1052 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1053 [ x"$ERROR" == x ] || error "back in time occured"
1055 run_test 54 "back in time"
1057 # bug 11330 - liblustre application death during I/O locks up OST
1059 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1063 # first dd should be finished quickly
1064 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1065 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1068 echo "step1: testing ......"
1070 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
1072 if [ $count -gt 64 ]; then
1073 error "dd should be finished!"
1077 echo "(dd_pid=$DDPID, time=$count)successful"
1079 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1080 #define OBD_FAIL_OST_DROP_REQ 0x21d
1081 do_facet ost1 lctl set_param fail_loc=0x0000021d
1082 # second dd will be never finished
1083 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1086 echo "step2: testing ......"
1087 while [ $count -le 64 ]; do
1088 dd_name="`ps x | awk '$1 == '$DDPID' { print $5 }'`"
1089 if [ -z $dd_name ]; then
1091 echo "debug: (dd_name=$dd_name, dd_pid=$DDPID, time=$count)"
1092 error "dd shouldn't be finished!"
1097 echo "(dd_pid=$DDPID, time=$count)successful"
1099 #Recover fail_loc and dd will finish soon
1100 do_facet ost1 lctl set_param fail_loc=0
1102 echo "step3: testing ......"
1104 if [ -z `ps x | awk '$1 == '$DDPID' { print $5 }'` ]; then break; fi
1106 if [ $count -gt 500 ]; then
1107 error "dd should be finished!"
1111 echo "(dd_pid=$DDPID, time=$count)successful"
1115 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1117 test_56() { # b=11277
1118 #define OBD_FAIL_MDS_RESEND 0x136
1120 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1122 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1125 run_test 56 "do not allow reconnect to busy exports"
1128 # no oscs means no client or mdt
1129 while lctl get_param osc.*.* > /dev/null 2>&1; do
1130 : # loop until proc file is removed
1134 test_57() { # bug 10866
1138 #define OBD_FAIL_LPROC_REMOVE 0xB00
1139 lctl set_param fail_loc=0x80000B00
1140 zconf_umount `hostname` $DIR
1141 lctl set_param fail_loc=0x80000B00
1142 fail_abort $SINGLEMDS
1144 lctl set_param fail_loc=0
1146 do_facet client "df $DIR"
1148 run_test 57 "read procfs entries causes kernel crash"
1150 test_58() { # bug 11546
1151 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1154 lctl set_param fail_loc=0x80000801
1155 cp $DIR/$tfile /dev/null &
1158 lctl set_param fail_loc=0
1159 drop_bl_callback rm -f $DIR/$tfile
1161 # the first 'df' could tigger the eviction caused by
1162 # 'drop_bl_callback', and it's normal case.
1163 # but the next 'df' should return successfully.
1164 do_facet client "df $DIR" || do_facet client "df $DIR"
1166 run_test 58 "Eviction in the middle of open RPC reply processing"
1168 test_59() { # bug 10589
1169 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1170 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1171 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1172 lctl set_param fail_loc=0x311
1173 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1174 [ $? = 0 ] || error "dd write failed"
1175 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1176 lctl set_param fail_loc=0
1178 zconf_umount `hostname` $MOUNT2 -f
1179 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1180 [ $? = 0 ] || error "dd read failed"
1181 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1182 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1184 run_test 59 "Read cancel race on client eviction"
1187 # we assume that all md changes are in the MDT0 changelog
1188 if [ $MDSCOUNT -gt 1 ]; then
1189 error_ignore 17935 $*
1196 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
1197 awk '{gsub(/_UUID/,""); print $1}' | head -1)
1202 # Register (and start) changelog
1203 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1204 echo "Registered as $MDT0 changelog user $USER"
1206 # Generate a large number of changelog entries
1207 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1211 # Unlink files in the background
1212 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1216 # Failover the MDS while unlinks are happening
1217 facet_failover $SINGLEMDS
1219 # Wait for unlinkmany to finish
1222 # Check if all the create/unlink events were recorded
1224 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1225 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1226 echo "$cl_count unlinks in $MDT0 changelog"
1228 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1229 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1230 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1231 if [ $USERS -eq 0 ]; then
1232 [ $cl_count -eq $NUM_FILES ] || \
1233 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1234 # Also make sure we can clear large changelogs
1235 cl_count=$($LFS changelog $FSNAME | wc -l)
1236 [ $cl_count -le 2 ] || \
1237 error "Changelog not empty: $cl_count entries"
1239 # If there are other users, there may be other unlinks in the log
1240 [ $cl_count -ge $NUM_FILES ] || \
1241 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1242 echo "$USERS other changelog users; can't verify clear"
1245 run_test 60 "Add Changelog entries during MDS failover"
1249 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1250 mdtosc=${mdtosc/-MDT*/-MDT\*}
1251 local cflags="osc.$mdtosc.connect_flags"
1252 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1253 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1255 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1256 # Set the default stripe of $DIR/$tdir to put the files to ost1
1257 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1259 replay_barrier $SINGLEMDS
1260 createmany -o $DIR/$tdir/$tfile-%d 10
1261 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1263 fail_abort $SINGLEMDS
1265 touch $DIR/$tdir/$tfile
1266 local id=`$LFS getstripe $DIR/$tdir/$tfile | awk '$1 == 0 { print $2 }'`
1267 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1272 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1274 # test_62 as seen it b2_1 please do not reuse test_62
1277 # zconf_umount `hostname` $DIR
1278 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1279 # lctl set_param fail_loc=0x516
1282 #run_test 62 "Verify connection flags race - bug LU-1716"
1284 check_cli_ir_state()
1286 local NODE=${1:-$HOSTNAME}
1288 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1289 awk '/imperative_recovery:/ { print \\\$2}'")
1290 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1291 error "Error state $st, must be ENABLED or DISABLED"
1295 check_target_ir_state()
1298 local name=${target}_svc
1299 local recovery_proc=obdfilter.${!name}.recovery_status
1302 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1303 awk '/IR:/{ print \\\$2}'")
1304 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1305 error "Error state $st, must be ENABLED or DISABLED"
1311 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1316 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1317 awk '/state:/{ print \\\$2 }'")
1321 nidtbl_version_mgs()
1323 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1324 awk '/nidtbl_version:/{ print \\\$2 }'")
1328 # nidtbl_version_client <mds1|client> [node]
1329 nidtbl_version_client()
1332 local node=${2:-$HOSTNAME}
1334 if [ X$cli = Xclient ]; then
1337 local obdtype=${cli/%[0-9]*/}
1338 [ $obdtype != mds ] && error "wrong parameters $cli"
1340 node=$(facet_active_host $cli)
1345 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1346 awk "/$cli/{print \$6}" |sort -u)
1348 # in case there are multiple mounts on the client node
1350 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1354 nidtbl_versions_match()
1356 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1359 target_instance_match()
1365 obdtype=${srv/%[0-9]*/}
1376 error "invalid target type" $srv
1381 local target=${srv}_svc
1382 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1383 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import | \
1384 awk '/instance/{ print $2 }' |head -1)
1386 return $([ $si -eq $ci ])
1391 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1392 { skip "MGS without IR support"; return 0; }
1394 # MDT was just restarted in the previous test, make sure everything
1397 while [ $cnt -gt 0 ]; do
1398 nidtbl_versions_match && break
1404 set_ir_status disabled
1406 local prev_ver=$(nidtbl_version_client client)
1408 local saved_FAILURE_MODE=$FAILURE_MODE
1409 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1413 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1414 error "version must not change due to IR disabled"
1415 target_instance_match ost1 || error "instance mismatch"
1419 FAILURE_MODE=$saved_FAILURE_MODE
1421 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1425 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1426 { skip "MGS without IR support"; return 0; }
1430 local OST1_IMP=$(get_osc_import_name client ost1)
1432 # disable pinger recovery
1433 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1437 target_instance_match ost1 || error "instance mismatch"
1438 nidtbl_versions_match || error "version must match"
1440 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1442 run_test 101 "IR: Make sure IR works w/o normal recovery"
1446 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1447 { skip "MGS without IR support"; return 0; }
1449 local clients=${CLIENTS:-$HOSTNAME}
1456 # let's have a new nidtbl version
1459 # sleep for a while so that clients can see the failure of ost
1460 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1461 # int mgc_request.c:
1462 # define MGC_TIMEOUT_MIN_SECONDS 5
1463 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1464 local count=30 # 20 seconds at most
1465 while [ $count -gt 0 ]; do
1466 nidtbl_versions_match && break
1471 nidtbl_versions_match || error "nidtbl mismatch"
1474 old_version=$(nidtbl_version_client client)
1476 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1479 combined_mgs_mds && mgsdev=mds1
1480 remount_facet $mgsdev
1483 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1486 new_version=$(nidtbl_version_client client)
1487 [ $new_version -lt $old_version ] &&
1488 error "nidtbl version wrong after mgs restarts"
1491 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1495 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1496 { skip "MGS without IR support"; return 0; }
1498 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1500 # workaround solution to generate config log on the mds
1506 # We need this test because mds is like a client in IR context.
1507 start mds1 $MDSDEV1 || error "MDS should start w/o mgs"
1509 # start mgs and remount mds w/ ir
1513 # remount client so that fsdb will be created on the MGS
1514 umount_client $MOUNT || error "umount failed"
1515 mount_client $MOUNT || error "mount failed"
1517 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1519 while [ $count -gt 0 ]; do
1520 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1525 # after a while, mds should be able to reconnect to mgs and fetch
1526 # up-to-date nidtbl version
1527 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1532 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1536 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1537 { skip "MGS without IR support"; return 0; }
1542 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1543 error "OST1 cannot start"
1546 local ir_state=$(check_target_ir_state ost1)
1547 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1548 error "ir status on ost1 should be DISABLED"
1550 run_test 104 "IR: ost can disable IR voluntarily"
1554 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1555 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1556 { skip "MGS without IR support"; return 0; }
1560 # get one of the clients from client list
1561 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1563 local old_MOUNTOPT=$MOUNTOPT
1564 MOUNTOPT=${MOUNTOPT},noir
1565 zconf_umount $rcli $MOUNT || error "umount failed"
1566 zconf_mount $rcli $MOUNT || error "mount failed"
1568 # make sure lustre mount at $rcli disabling IR
1569 local ir_state=$(check_cli_ir_state $rcli)
1570 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1571 error "IR state must be DISABLED at $rcli"
1573 # Since the client just mounted, its last_rcvd entry is not on disk.
1574 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1575 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1576 $SETSTRIPE -i 0 $DIR/$tfile
1577 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1579 # make sure MGS's state is Partial
1580 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1583 # make sure IR on ost1 is DISABLED
1584 local ir_state=$(check_target_ir_state ost1)
1585 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1586 error "IR status on ost1 should be DISABLED"
1589 MOUNTOPT=$old_MOUNTOPT
1590 zconf_umount $rcli $MOUNT || error "umount failed"
1591 zconf_mount $rcli $MOUNT || error "mount failed"
1593 # make sure MGS's state is full
1594 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1597 # make sure IR on ost1 is ENABLED
1598 local ir_state=$(check_target_ir_state ost1)
1599 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1600 error "IR status on ost1 should be ENABLED"
1604 run_test 105 "IR: NON IR clients support"
1612 test_106() { # LU-1789
1613 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1614 { skip "Need MDS version at least 2.3.50"; return 0; }
1616 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1617 $LCTL set_param fail_loc=0x805
1620 trap cleanup_106 EXIT
1622 # enable lightweight flag on mdc connection
1625 local MDS_NEXP=$(do_facet $SINGLEMDS \
1626 lctl get_param -n mdt.${mds1_svc}.num_exports |
1628 $LCTL set_param fail_loc=0
1630 touch $DIR2/$tfile || error "failed to create empty file"
1631 replay_barrier $SINGLEMDS
1633 $LCTL set_param debug=console
1635 facet_failover $SINGLEMDS
1637 # lightweight connection must be evicted
1638 touch -c $DIR2/$tfile || true
1639 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1640 evicted=`awk '/This client was evicted by .*MDT0000/ {
1642 }' $TMP/lustre-log-$TESTNAME.log`
1643 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1645 # and all operations performed by lightweight client should be
1646 # synchronous, so the file created before mds restart should be there
1647 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1652 run_test 106 "lightweight connection support"
1659 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1660 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1661 multiop $DIR/$tdir D_c &
1663 mkdir $DIR/$tdir/dir_106 &
1665 do_facet $SINGLEMDS lctl set_param fail_loc=0
1668 wait $CLIENT_PID || rc=$?
1669 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1671 kill -USR1 $close_pid
1672 wait $close_pid || return 2
1676 run_test 107 "drop reint reply, then restart MDT"
1679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1680 local remote_dir=$DIR/$tdir/remote_dir
1684 drop_request "$LFS mkdir -i $MDTIDX $remote_dir" ||
1685 error "lfs mkdir failed"
1686 local diridx=$($GETSTRIPE -M $remote_dir)
1687 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1689 rm -rf $DIR/$tdir || error "rmdir failed"
1691 run_test 110a "create remote directory: drop client req"
1694 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1695 local remote_dir=$DIR/$tdir/remote_dir
1699 drop_reint_reply "$LFS mkdir -i $MDTIDX $remote_dir" ||
1700 error "lfs mkdir failed"
1702 diridx=$($GETSTRIPE -M $remote_dir)
1703 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1705 rm -rf $DIR/$tdir || error "rmdir failed"
1707 run_test 110b "create remote directory: drop Master rep"
1710 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1711 local remote_dir=$DIR/$tdir/remote_dir
1715 drop_update_reply $((MDTIDX + 1)) "$LFS mkdir -i $MDTIDX $remote_dir" ||
1716 error "lfs mkdir failed"
1718 diridx=$($GETSTRIPE -M $remote_dir)
1719 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1721 rm -rf $DIR/$tdir || error "rmdir failed"
1723 run_test 110c "create remote directory: drop update rep on slave MDT"
1726 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1727 local remote_dir=$DIR/$tdir/remote_dir
1731 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
1733 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1735 rm -rf $DIR/$tdir || error "rmdir failed"
1739 run_test 110d "remove remote directory: drop client req"
1742 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1743 local remote_dir=$DIR/$tdir/remote_dir
1747 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
1748 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1750 rm -rf $DIR/$tdir || error "rmdir failed"
1754 run_test 110e "remove remote directory: drop master rep"
1757 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1758 local remote_dir=$DIR/$tdir/remote_dir
1762 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
1763 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1764 error "rm remote dir failed"
1766 rm -rf $DIR/$tdir || error "rmdir failed"
1768 run_test 110f "remove remote directory: drop slave rep"
1770 # LU-2844 mdt prepare fail should not cause umount oops
1772 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1773 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
1774 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
1775 stop $SINGLEMDS || error "stop MDS failed"
1776 start $SINGLEMDS $mdsdev && error "start MDS should fail"
1777 do_facet $SINGLEMDS lctl set_param fail_loc=0
1778 start $SINGLEMDS $mdsdev || error "start MDS failed"
1780 run_test 111 "mdd setup fail should not cause umount oops"
1783 check_and_cleanup_lustre